annotate src/hardcopy.c @ 32164:673dcbaded32 v9.0.1413

patch 9.0.1413: compiler warning for unused variable Commit: https://github.com/vim/vim/commit/2a003177eb3cee535bb8a384b4b87db13f0486ae Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 17 18:50:48 2023 +0000 patch 9.0.1413: compiler warning for unused variable Problem: Compiler warning for unused variable. Solution: Move variable declaration. (John Marriott)
author Bram Moolenaar <Bram@vim.org>
date Fri, 17 Mar 2023 20:00:06 +0100
parents 97255d909654
children 1629cc65d78d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9027
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
4 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
8 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
9
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
10 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
11 * hardcopy.c: printing to paper
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
12 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
13
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
14 #include "vim.h"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
15 #include "version.h"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
16
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
17 #if defined(FEAT_PRINTER) || defined(PROTO)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
18 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
19 * To implement printing on a platform, the following functions must be
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
20 * defined:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
21 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
22 * int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
23 * Called once. Code should display printer dialogue (if appropriate) and
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
24 * determine printer font and margin settings. Reset has_color if the printer
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
25 * doesn't support colors at all.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
26 * Returns FAIL to abort.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
27 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
28 * int mch_print_begin(prt_settings_T *settings)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
29 * Called to start the print job.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
30 * Return FALSE to abort.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
31 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
32 * int mch_print_begin_page(char_u *msg)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
33 * Called at the start of each page.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
34 * "msg" indicates the progress of the print job, can be NULL.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
35 * Return FALSE to abort.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
36 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
37 * int mch_print_end_page()
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
38 * Called at the end of each page.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
39 * Return FALSE to abort.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
40 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
41 * int mch_print_blank_page()
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
42 * Called to generate a blank page for collated, duplex, multiple copy
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
43 * document. Return FALSE to abort.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
44 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
45 * void mch_print_end(prt_settings_T *psettings)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
46 * Called at normal end of print job.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
47 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
48 * void mch_print_cleanup()
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
49 * Called if print job ends normally or is abandoned. Free any memory, close
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
50 * devices and handles. Also called when mch_print_begin() fails, but not
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
51 * when mch_print_init() fails.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
52 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
53 * void mch_print_set_font(int Bold, int Italic, int Underline);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
54 * Called whenever the font style changes.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
55 *
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 840
diff changeset
56 * void mch_print_set_bg(long_u bgcol);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
57 * Called to set the background color for the following text. Parameter is an
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
58 * RGB value.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
59 *
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 840
diff changeset
60 * void mch_print_set_fg(long_u fgcol);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
61 * Called to set the foreground color for the following text. Parameter is an
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
62 * RGB value.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
63 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
64 * mch_print_start_line(int margin, int page_line)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
65 * Sets the current position at the start of line "page_line".
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
66 * If margin is TRUE start in the left margin (for header and line number).
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
67 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
68 * int mch_print_text_out(char_u *p, int len);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
69 * Output one character of text p[len] at the current position.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
70 * Return TRUE if there is no room for another character in the same line.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
71 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
72 * Note that the generic code has no idea of margins. The machine code should
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
73 * simply make the page look smaller! The header and the line numbers are
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
74 * printed in the margin.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
75 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
76
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
77 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
78 static const long_u cterm_color_8[8] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
79 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
80 (long_u)0x000000L, (long_u)0xff0000L, (long_u)0x00ff00L, (long_u)0xffff00L,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
81 (long_u)0x0000ffL, (long_u)0xff00ffL, (long_u)0x00ffffL, (long_u)0xffffffL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
82 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
83
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
84 static const long_u cterm_color_16[16] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
85 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
86 (long_u)0x000000L, (long_u)0x0000c0L, (long_u)0x008000L, (long_u)0x004080L,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
87 (long_u)0xc00000L, (long_u)0xc000c0L, (long_u)0x808000L, (long_u)0xc0c0c0L,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
88 (long_u)0x808080L, (long_u)0x6060ffL, (long_u)0x00ff00L, (long_u)0x00ffffL,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
89 (long_u)0xff8080L, (long_u)0xff40ffL, (long_u)0xffff00L, (long_u)0xffffffL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
90 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
91
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
92 static int current_syn_id;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
93 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
94
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
95 #define PRCOLOR_BLACK (long_u)0
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
96 #define PRCOLOR_WHITE (long_u)0xFFFFFFL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
97
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
98 static int curr_italic;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
99 static int curr_bold;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
100 static int curr_underline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
101 static long_u curr_bg;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
102 static long_u curr_fg;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
103 static int page_count;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
104
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
105 #if defined(FEAT_POSTSCRIPT)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
106 # define OPT_MBFONT_USECOURIER 0
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
107 # define OPT_MBFONT_ASCII 1
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
108 # define OPT_MBFONT_REGULAR 2
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
109 # define OPT_MBFONT_BOLD 3
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
110 # define OPT_MBFONT_OBLIQUE 4
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
111 # define OPT_MBFONT_BOLDOBLIQUE 5
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
112 # define OPT_MBFONT_NUM_OPTIONS 6
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
113
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
114 static option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
115 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
116 {"c", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
117 {"a", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
118 {"r", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
119 {"b", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
120 {"i", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
121 {"o", FALSE, 0, NULL, 0, FALSE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
122 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
123 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
124
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
125 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
126 * These values determine the print position on a page.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
127 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
128 typedef struct
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
129 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
130 int lead_spaces; // remaining spaces for a TAB
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
131 int print_pos; // virtual column for computing TABs
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
132 colnr_T column; // byte column
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
133 linenr_T file_line; // line nr in the buffer
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
134 long_u bytes_printed; // bytes printed so far
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
135 int ff; // seen form feed character
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
136 } prt_pos_T;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
137
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
138 static char *parse_list_options(char_u *option_str, option_table_T *table, int table_size);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
139
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 6759
diff changeset
140 static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T *ppos);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
141
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
142 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
143 * Parse 'printoptions' and set the flags in "printer_opts".
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
144 * Returns an error message or NULL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
145 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
146 char *
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31667
diff changeset
147 parse_printoptions(optset_T *args UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
148 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
149 return parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
150 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
151
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
152 #if defined(FEAT_POSTSCRIPT) || defined(PROTO)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
153 /*
8969
c83e2c1e7f2b commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents: 8829
diff changeset
154 * Parse 'printmbfont' and set the flags in "mbfont_opts".
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
155 * Returns an error message or NULL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
156 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
157 char *
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31667
diff changeset
158 parse_printmbfont(optset_T *args UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
159 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
160 return parse_list_options(p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
161 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
162 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
163
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
164 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
165 * Parse a list of options in the form
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
166 * option:value,option:value,option:value
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
167 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
168 * "value" can start with a number which is parsed out, e.g. margin:12mm
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
169 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
170 * Returns an error message for an illegal option, NULL otherwise.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
171 * Only used for the printer at the moment...
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
172 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
173 static char *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
174 parse_list_options(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
175 char_u *option_str,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
176 option_table_T *table,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
177 int table_size)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
178 {
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
179 option_table_T *old_opts;
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
180 char *ret = NULL;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
181 char_u *stringp;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
182 char_u *colonp;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
183 char_u *commap;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
184 char_u *p;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
185 int idx = 0; // init for GCC
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
186 int len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
187
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
188 // Save the old values, so that they can be restored in case of an error.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16621
diff changeset
189 old_opts = ALLOC_MULT(option_table_T, table_size);
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
190 if (old_opts == NULL)
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
191 return NULL;
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
192
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
193 for (idx = 0; idx < table_size; ++idx)
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
194 {
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
195 old_opts[idx] = table[idx];
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
196 table[idx].present = FALSE;
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
197 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
198
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
199 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
200 * Repeat for all comma separated parts.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
201 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
202 stringp = option_str;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
203 while (*stringp)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
204 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
205 colonp = vim_strchr(stringp, ':');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
206 if (colonp == NULL)
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
207 {
26917
d91aea2a612c patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
208 ret = e_missing_colon_3;
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
209 break;
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
210 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
211 commap = vim_strchr(stringp, ',');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
212 if (commap == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
213 commap = option_str + STRLEN(option_str);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
214
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
215 len = (int)(colonp - stringp);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
216
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
217 for (idx = 0; idx < table_size; ++idx)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
218 if (STRNICMP(stringp, table[idx].name, len) == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
219 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
220
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
221 if (idx == table_size)
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
222 {
26917
d91aea2a612c patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
223 ret = e_illegal_component;
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
224 break;
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
225 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
226 p = colonp + 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
227 table[idx].present = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
228
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
229 if (table[idx].hasnum)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
230 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
231 if (!VIM_ISDIGIT(*p))
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
232 {
26917
d91aea2a612c patch 8.2.3987: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
233 ret = e_digit_expected_2;
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
234 break;
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
235 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
236
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
237 table[idx].number = getdigits(&p); // advances p
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
238 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
239
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
240 table[idx].string = p;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
241 table[idx].strlen = (int)(commap - p);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
242
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
243 stringp = commap;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
244 if (*stringp == ',')
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
245 ++stringp;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
246 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
247
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
248 if (ret != NULL)
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
249 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
250 // Restore old options in case of error
8829
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
251 for (idx = 0; idx < table_size; ++idx)
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
252 table[idx] = old_opts[idx];
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
253 }
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
254 vim_free(old_opts);
a2c27f6aaf3a commit https://github.com/vim/vim/commit/4afc7c5d4a73340831077a02bfe1f74935e7f4a1
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
255 return ret;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
256 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
257
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
258
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
259 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
260 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
261 * If using a dark background, the colors will probably be too bright to show
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
262 * up well on white paper, so reduce their brightness.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
263 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
264 static long_u
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
265 darken_rgb(long_u rgb)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
266 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
267 return ((rgb >> 17) << 16)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
268 + (((rgb & 0xff00) >> 9) << 8)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
269 + ((rgb & 0xff) >> 1);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
270 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
271
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
272 static long_u
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
273 prt_get_term_color(int colorindex)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
274 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
275 // TODO: Should check for xterm with 88 or 256 colors.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
276 if (t_colors > 8)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
277 return cterm_color_16[colorindex % 16];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
278 return cterm_color_8[colorindex % 8];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
279 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
280
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
281 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
282 prt_get_attr(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
283 int hl_id,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
284 prt_text_attr_T *pattr,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
285 int modec)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
286 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
287 int colorindex;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
288 long_u fg_color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
289 long_u bg_color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
290 char *color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
291
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
292 pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
293 pattr->italic = (highlight_has_attr(hl_id, HL_ITALIC, modec) != NULL);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
294 pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
295 pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
29328
60977de70684 patch 9.0.0007: no support for double, dotted and dashed underlines
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
296 // TODO: HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
297
9027
773d627cac0b commit https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
Christian Brabandt <cb@256bit.org>
parents: 8969
diff changeset
298 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
8969
c83e2c1e7f2b commit https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
Christian Brabandt <cb@256bit.org>
parents: 8829
diff changeset
299 if (USE_24BIT)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
300 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
301 bg_color = highlight_gui_color_rgb(hl_id, FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
302 if (bg_color == PRCOLOR_BLACK)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
303 bg_color = PRCOLOR_WHITE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
304
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
305 fg_color = highlight_gui_color_rgb(hl_id, TRUE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
306 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
307 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
308 # endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
309 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
310 bg_color = PRCOLOR_WHITE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
311
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
312 color = (char *)highlight_color(hl_id, (char_u *)"fg", modec);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
313 if (color == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
314 colorindex = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
315 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
316 colorindex = atoi(color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
317
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
318 if (colorindex >= 0 && colorindex < t_colors)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
319 fg_color = prt_get_term_color(colorindex);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
320 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
321 fg_color = PRCOLOR_BLACK;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
322 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
323
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
324 if (fg_color == PRCOLOR_WHITE)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
325 fg_color = PRCOLOR_BLACK;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
326 else if (*p_bg == 'd')
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
327 fg_color = darken_rgb(fg_color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
328
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
329 pattr->fg_color = fg_color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
330 pattr->bg_color = bg_color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
331 }
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
332 #endif // FEAT_SYN_HL
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
333
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
334 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
335 prt_set_fg(long_u fg)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
336 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
337 if (fg == curr_fg)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
338 return;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
339
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
340 curr_fg = fg;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
341 mch_print_set_fg(fg);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
342 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
343
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
344 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
345 prt_set_bg(long_u bg)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
346 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
347 if (bg == curr_bg)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
348 return;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
349
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
350 curr_bg = bg;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
351 mch_print_set_bg(bg);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
352 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
353
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
354 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
355 prt_set_font(int bold, int italic, int underline)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
356 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
357 if (curr_bold == bold
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
358 && curr_italic == italic
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
359 && curr_underline == underline)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
360 return;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
361
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
362 curr_underline = underline;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
363 curr_italic = italic;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
364 curr_bold = bold;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
365 mch_print_set_font(bold, italic, underline);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
366 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
367
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
368 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
369 * Print the line number in the left margin.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
370 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
371 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
372 prt_line_number(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
373 prt_settings_T *psettings,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
374 int page_line,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
375 linenr_T lnum)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
376 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
377 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
378 char_u tbuf[20];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
379
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
380 prt_set_fg(psettings->number.fg_color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
381 prt_set_bg(psettings->number.bg_color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
382 prt_set_font(psettings->number.bold, psettings->number.italic, psettings->number.underline);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
383 mch_print_start_line(TRUE, page_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
384
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
385 // Leave two spaces between the number and the text; depends on
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
386 // PRINT_NUMBER_WIDTH.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
387 sprintf((char *)tbuf, "%6ld", (long)lnum);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
388 for (i = 0; i < 6; i++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
389 (void)mch_print_text_out(&tbuf[i], 1);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
390
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
391 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
392 if (psettings->do_syntax)
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
393 // Set colors for next character.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
394 current_syn_id = -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
395 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
396 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
397 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
398 // Set colors and font back to normal.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
399 prt_set_fg(PRCOLOR_BLACK);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
400 prt_set_bg(PRCOLOR_WHITE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
401 prt_set_font(FALSE, FALSE, FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
402 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
403 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
404
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
405 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
406 * Get the currently effective header height.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
407 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
408 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
409 prt_header_height(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
410 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
411 if (printer_opts[OPT_PRINT_HEADERHEIGHT].present)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
412 return printer_opts[OPT_PRINT_HEADERHEIGHT].number;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
413 return 2;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
414 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
415
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
416 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
417 * Return TRUE if using a line number for printing.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
418 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
419 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
420 prt_use_number(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
421 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
422 return (printer_opts[OPT_PRINT_NUMBER].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
423 && TOLOWER_ASC(printer_opts[OPT_PRINT_NUMBER].string[0]) == 'y');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
424 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
425
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
426 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
427 * Return the unit used in a margin item in 'printoptions'.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
428 * Returns PRT_UNIT_NONE if not recognized.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
429 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
430 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
431 prt_get_unit(int idx)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
432 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
433 int u = PRT_UNIT_NONE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
434 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
435 static char *(units[4]) = PRT_UNIT_NAMES;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
436
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
437 if (!printer_opts[idx].present)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
438 return PRT_UNIT_NONE;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
439
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
440 for (i = 0; i < 4; ++i)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
441 if (STRNICMP(printer_opts[idx].string, units[i], 2) == 0)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
442 {
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
443 u = i;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
444 break;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
445 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
446 return u;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
447 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
448
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
449 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
450 * Print the page header.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
451 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
452 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
453 prt_header(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
454 prt_settings_T *psettings,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
455 int pagenum,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
456 linenr_T lnum UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
457 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
458 int width = psettings->chars_per_line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
459 int page_line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
460 char_u *tbuf;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
461 char_u *p;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
462 int l;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
463
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
464 // Also use the space for the line number.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
465 if (prt_use_number())
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
466 width += PRINT_NUMBER_WIDTH;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
467
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
468 tbuf = alloc(width + IOSIZE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
469 if (tbuf == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
470 return;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
471
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
472 #ifdef FEAT_STL_OPT
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
473 if (*p_header != NUL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
474 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
475 linenr_T tmp_lnum, tmp_topline, tmp_botline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
476
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
477 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
478 * Need to (temporarily) set current line number and first/last line
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
479 * number on the 'window'. Since we don't know how long the page is,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
480 * set the first and current line number to the top line, and guess
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
481 * that the page length is 64.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
482 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
483 tmp_lnum = curwin->w_cursor.lnum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
484 tmp_topline = curwin->w_topline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
485 tmp_botline = curwin->w_botline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
486 curwin->w_cursor.lnum = lnum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
487 curwin->w_topline = lnum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
488 curwin->w_botline = lnum + 63;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
489 printer_page_num = pagenum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
490
31018
9716c7d24c12 patch 9.0.0844: handling 'statusline' errors is spread out
Bram Moolenaar <Bram@vim.org>
parents: 29328
diff changeset
491 build_stl_str_hl(curwin, tbuf, (size_t)(width + IOSIZE), p_header,
9716c7d24c12 patch 9.0.0844: handling 'statusline' errors is spread out
Bram Moolenaar <Bram@vim.org>
parents: 29328
diff changeset
492 (char_u *)"printheader", 0, ' ', width, NULL, NULL);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
493
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
494 // Reset line numbers
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
495 curwin->w_cursor.lnum = tmp_lnum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
496 curwin->w_topline = tmp_topline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
497 curwin->w_botline = tmp_botline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
498 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
499 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
500 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
501 sprintf((char *)tbuf, _("Page %d"), pagenum);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
502
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
503 prt_set_fg(PRCOLOR_BLACK);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
504 prt_set_bg(PRCOLOR_WHITE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
505 prt_set_font(TRUE, FALSE, FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
506
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
507 // Use a negative line number to indicate printing in the top margin.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
508 page_line = 0 - prt_header_height();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
509 mch_print_start_line(TRUE, page_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
510 for (p = tbuf; *p != NUL; )
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
511 {
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
512 if (mch_print_text_out(p, (l = (*mb_ptr2len)(p))))
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
513 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
514 ++page_line;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
515 if (page_line >= 0) // out of room in header
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
516 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
517 mch_print_start_line(TRUE, page_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
518 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
519 p += l;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
520 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
521
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
522 vim_free(tbuf);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
523
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
524 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
525 if (psettings->do_syntax)
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
526 // Set colors for next character.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
527 current_syn_id = -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
528 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
529 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
530 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
531 // Set colors and font back to normal.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
532 prt_set_fg(PRCOLOR_BLACK);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
533 prt_set_bg(PRCOLOR_WHITE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
534 prt_set_font(FALSE, FALSE, FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
535 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
536 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
537
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
538 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
539 * Display a print status message.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
540 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
541 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
542 prt_message(char_u *s)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
543 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
544 screen_fill((int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
11158
501f46f7644c patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
545 screen_puts(s, (int)Rows - 1, 0, HL_ATTR(HLF_R));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
546 out_flush();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
547 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
548
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
549 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
550 ex_hardcopy(exarg_T *eap)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
551 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
552 linenr_T lnum;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
553 int collated_copies, uncollated_copies;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
554 prt_settings_T settings;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
555 long_u bytes_to_print = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
556 int page_line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
557 int jobsplit;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
558
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 18798
diff changeset
559 CLEAR_FIELD(settings);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
560 settings.has_color = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
561
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
562 # ifdef FEAT_POSTSCRIPT
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
563 if (*eap->arg == '>')
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
564 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
565 char *errormsg = NULL;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
566
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
567 // Expand things like "%.ps".
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
568 if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
569 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
570 if (errormsg != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
571 emsg(errormsg);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
572 return;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
573 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
574 settings.outfile = skipwhite(eap->arg + 1);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
575 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
576 else if (*eap->arg != NUL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
577 settings.arguments = eap->arg;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
578 # endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
579
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
580 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
581 * Initialise for printing. Ask the user for settings, unless forceit is
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
582 * set.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
583 * The mch_print_init() code should set up margins if applicable. (It may
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
584 * not be a real printer - for example the engine might generate HTML or
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
585 * PS.)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
586 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
587 if (mch_print_init(&settings,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
588 curbuf->b_fname == NULL
25852
336e2d9924e6 patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
589 ? buf_spname(curbuf)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
590 : curbuf->b_sfname == NULL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
591 ? curbuf->b_fname
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
592 : curbuf->b_sfname,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
593 eap->forceit) == FAIL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
594 return;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
595
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
596 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
597 # ifdef FEAT_GUI
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
598 if (gui.in_use)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
599 settings.modec = 'g';
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
600 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
601 # endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
602 if (t_colors > 1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
603 settings.modec = 'c';
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
604 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
605 settings.modec = 't';
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
606
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
607 if (!syntax_present(curwin))
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
608 settings.do_syntax = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
609 else if (printer_opts[OPT_PRINT_SYNTAX].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
610 && TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) != 'a')
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
611 settings.do_syntax =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
612 (TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) == 'y');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
613 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
614 settings.do_syntax = settings.has_color;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
615 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
616
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
617 // Set up printing attributes for line numbers
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
618 settings.number.fg_color = PRCOLOR_BLACK;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
619 settings.number.bg_color = PRCOLOR_WHITE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
620 settings.number.bold = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
621 settings.number.italic = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
622 settings.number.underline = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
623 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
624 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
625 * Syntax highlighting of line numbers.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
626 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
627 if (prt_use_number() && settings.do_syntax)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
628 {
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 688
diff changeset
629 int id;
07f7b4a7755c updated for version 7.0222
vimboss
parents: 688
diff changeset
630
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
631 id = syn_name2id((char_u *)"LineNr");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
632 if (id > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
633 id = syn_get_final_id(id);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
634
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
635 prt_get_attr(id, &settings.number, settings.modec);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
636 }
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 688
diff changeset
637 #endif
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
638
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
639 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
640 * Estimate the total lines to be printed
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
641 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
642 for (lnum = eap->line1; lnum <= eap->line2; lnum++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
643 bytes_to_print += (long_u)STRLEN(skipwhite(ml_get(lnum)));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
644 if (bytes_to_print == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
645 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
646 msg(_("No text to be printed"));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
647 goto print_fail_no_begin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
648 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
649
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
650 // Set colors and font to normal.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
651 curr_bg = (long_u)0xffffffffL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
652 curr_fg = (long_u)0xffffffffL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
653 curr_italic = MAYBE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
654 curr_bold = MAYBE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
655 curr_underline = MAYBE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
656
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
657 prt_set_fg(PRCOLOR_BLACK);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
658 prt_set_bg(PRCOLOR_WHITE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
659 prt_set_font(FALSE, FALSE, FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
660 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
661 current_syn_id = -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
662 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
663
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
664 jobsplit = (printer_opts[OPT_PRINT_JOBSPLIT].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
665 && TOLOWER_ASC(printer_opts[OPT_PRINT_JOBSPLIT].string[0]) == 'y');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
666
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
667 if (!mch_print_begin(&settings))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
668 goto print_fail_no_begin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
669
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
670 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
671 * Loop over collated copies: 1 2 3, 1 2 3, ...
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
672 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
673 page_count = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
674 for (collated_copies = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
675 collated_copies < settings.n_collated_copies;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
676 collated_copies++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
677 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
678 prt_pos_T prtpos; // current print position
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
679 prt_pos_T page_prtpos; // print position at page start
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
680 int side;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
681
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 18798
diff changeset
682 CLEAR_FIELD(page_prtpos);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
683 page_prtpos.file_line = eap->line1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
684 prtpos = page_prtpos;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
685
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
686 if (jobsplit && collated_copies > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
687 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
688 // Splitting jobs: Stop a previous job and start a new one.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
689 mch_print_end(&settings);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
690 if (!mch_print_begin(&settings))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
691 goto print_fail_no_begin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
692 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
693
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
694 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
695 * Loop over all pages in the print job: 1 2 3 ...
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
696 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
697 for (page_count = 0; prtpos.file_line <= eap->line2; ++page_count)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
698 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
699 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
700 * Loop over uncollated copies: 1 1 1, 2 2 2, 3 3 3, ...
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
701 * For duplex: 12 12 12 34 34 34, ...
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
702 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
703 for (uncollated_copies = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
704 uncollated_copies < settings.n_uncollated_copies;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
705 uncollated_copies++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
706 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
707 // Set the print position to the start of this page.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
708 prtpos = page_prtpos;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
709
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
710 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
711 * Do front and rear side of a page.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
712 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
713 for (side = 0; side <= settings.duplex; ++side)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
714 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
715 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
716 * Print one page.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
717 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
718
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
719 // Check for interrupt character every page.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
720 ui_breakcheck();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
721 if (got_int || settings.user_abort)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
722 goto print_fail;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
723
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
724 sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
725 page_count + 1 + side,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
726 prtpos.bytes_printed > 1000000
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
727 ? (int)(prtpos.bytes_printed /
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
728 (bytes_to_print / 100))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
729 : (int)((prtpos.bytes_printed * 100)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
730 / bytes_to_print));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
731 if (!mch_print_begin_page(IObuff))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
732 goto print_fail;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
733
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
734 if (settings.n_collated_copies > 1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
735 sprintf((char *)IObuff + STRLEN(IObuff),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
736 _(" Copy %d of %d"),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
737 collated_copies + 1,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
738 settings.n_collated_copies);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
739 prt_message(IObuff);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
740
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
741 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
742 * Output header if required
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
743 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
744 if (prt_header_height() > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
745 prt_header(&settings, page_count + 1 + side,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
746 prtpos.file_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
747
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
748 for (page_line = 0; page_line < settings.lines_per_page;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
749 ++page_line)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
750 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
751 prtpos.column = hardcopy_line(&settings,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
752 page_line, &prtpos);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
753 if (prtpos.column == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
754 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
755 // finished a file line
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
756 prtpos.bytes_printed +=
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
757 STRLEN(skipwhite(ml_get(prtpos.file_line)));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
758 if (++prtpos.file_line > eap->line2)
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
759 break; // reached the end
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
760 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
761 else if (prtpos.ff)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
762 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
763 // Line had a formfeed in it - start new page but
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
764 // stay on the current line
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
765 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
766 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
767 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
768
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
769 if (!mch_print_end_page())
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
770 goto print_fail;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
771 if (prtpos.file_line > eap->line2)
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
772 break; // reached the end
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
773 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
774
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
775 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
776 * Extra blank page for duplexing with odd number of pages and
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
777 * more copies to come.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
778 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
779 if (prtpos.file_line > eap->line2 && settings.duplex
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
780 && side == 0
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
781 && uncollated_copies + 1 < settings.n_uncollated_copies)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
782 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
783 if (!mch_print_blank_page())
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
784 goto print_fail;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
785 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
786 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
787 if (settings.duplex && prtpos.file_line <= eap->line2)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
788 ++page_count;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
789
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
790 // Remember the position where the next page starts.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
791 page_prtpos = prtpos;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
792 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
793
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
794 vim_snprintf((char *)IObuff, IOSIZE, _("Printed: %s"),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
795 settings.jobname);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
796 prt_message(IObuff);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
797 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
798
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
799 print_fail:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
800 if (got_int || settings.user_abort)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
801 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
802 sprintf((char *)IObuff, "%s", _("Printing aborted"));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
803 prt_message(IObuff);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
804 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
805 mch_print_end(&settings);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
806
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
807 print_fail_no_begin:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
808 mch_print_cleanup();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
809 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
810
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
811 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
812 * Print one page line.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
813 * Return the next column to print, or zero if the line is finished.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
814 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
815 static colnr_T
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
816 hardcopy_line(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
817 prt_settings_T *psettings,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
818 int page_line,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
819 prt_pos_T *ppos)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
820 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
821 colnr_T col;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
822 char_u *line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
823 int need_break = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
824 int outputlen;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
825 int tab_spaces;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
826 long_u print_pos;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
827 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
828 prt_text_attr_T attr;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
829 int id;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
830 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
831
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
832 if (ppos->column == 0 || ppos->ff)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
833 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
834 print_pos = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
835 tab_spaces = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
836 if (!ppos->ff && prt_use_number())
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
837 prt_line_number(psettings, page_line, ppos->file_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
838 ppos->ff = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
839 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
840 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
841 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
842 // left over from wrap halfway a tab
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
843 print_pos = ppos->print_pos;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
844 tab_spaces = ppos->lead_spaces;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
845 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
846
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
847 mch_print_start_line(0, page_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
848 line = ml_get(ppos->file_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
849
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
850 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
851 * Loop over the columns until the end of the file line or right margin.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
852 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
853 for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
854 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
855 outputlen = 1;
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 442
diff changeset
856 if (has_mbyte && (outputlen = (*mb_ptr2len)(line + col)) < 1)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
857 outputlen = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
858 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
859 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
860 * syntax highlighting stuff.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
861 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
862 if (psettings->do_syntax)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
863 {
1504
1b55bbf5c580 updated for version 7.1-219
vimboss
parents: 1218
diff changeset
864 id = syn_get_id(curwin, ppos->file_line, col, 1, NULL, FALSE);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
865 if (id > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
866 id = syn_get_final_id(id);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
867 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
868 id = 0;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
869 // Get the line again, a multi-line regexp may invalidate it.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
870 line = ml_get(ppos->file_line);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
871
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
872 if (id != current_syn_id)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
873 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
874 current_syn_id = id;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
875 prt_get_attr(id, &attr, psettings->modec);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
876 prt_set_font(attr.bold, attr.italic, attr.underline);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
877 prt_set_fg(attr.fg_color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
878 prt_set_bg(attr.bg_color);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
879 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
880 }
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 688
diff changeset
881 #endif
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
882
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
883 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
884 * Appropriately expand any tabs to spaces.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
885 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
886 if (line[col] == TAB || tab_spaces != 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
887 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
888 if (tab_spaces == 0)
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14077
diff changeset
889 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14077
diff changeset
890 tab_spaces = tabstop_padding(print_pos, curbuf->b_p_ts,
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14077
diff changeset
891 curbuf->b_p_vts_array);
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14077
diff changeset
892 #else
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
893 tab_spaces = (int)(curbuf->b_p_ts - (print_pos % curbuf->b_p_ts));
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14077
diff changeset
894 #endif
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
895
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
896 while (tab_spaces > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
897 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
898 need_break = mch_print_text_out((char_u *)" ", 1);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
899 print_pos++;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
900 tab_spaces--;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
901 if (need_break)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
902 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
903 }
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
904 // Keep the TAB if we didn't finish it.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
905 if (need_break && tab_spaces > 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
906 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
907 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
908 else if (line[col] == FF
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
909 && printer_opts[OPT_PRINT_FORMFEED].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
910 && TOLOWER_ASC(printer_opts[OPT_PRINT_FORMFEED].string[0])
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
911 == 'y')
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
912 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
913 ppos->ff = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
914 need_break = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
915 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
916 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
917 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
918 need_break = mch_print_text_out(line + col, outputlen);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
919 if (has_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
920 print_pos += (*mb_ptr2cells)(line + col);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
921 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
922 print_pos++;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
923 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
924 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
925
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
926 ppos->lead_spaces = tab_spaces;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
927 ppos->print_pos = (int)print_pos;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
928
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
929 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
930 * Start next line of file if we clip lines, or have reached end of the
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
931 * line, unless we are doing a formfeed.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
932 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
933 if (!ppos->ff
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
934 && (line[col] == NUL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
935 || (printer_opts[OPT_PRINT_WRAP].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
936 && TOLOWER_ASC(printer_opts[OPT_PRINT_WRAP].string[0])
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
937 == 'n')))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
938 return 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
939 return col;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
940 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
941
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
942 # if defined(FEAT_POSTSCRIPT) || defined(PROTO)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
943
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
944 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
945 * PS printer stuff.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
946 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
947 * Sources of information to help maintain the PS printing code:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
948 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
949 * 1. PostScript Language Reference, 3rd Edition,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
950 * Addison-Wesley, 1999, ISBN 0-201-37922-8
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
951 * 2. PostScript Language Program Design,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
952 * Addison-Wesley, 1988, ISBN 0-201-14396-8
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
953 * 3. PostScript Tutorial and Cookbook,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
954 * Addison Wesley, 1985, ISBN 0-201-10179-3
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
955 * 4. PostScript Language Document Structuring Conventions Specification,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
956 * version 3.0,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
957 * Adobe Technote 5001, 25th September 1992
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
958 * 5. PostScript Printer Description File Format Specification, Version 4.3,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
959 * Adobe technote 5003, 9th February 1996
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
960 * 6. Adobe Font Metrics File Format Specification, Version 4.1,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
961 * Adobe Technote 5007, 7th October 1998
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
962 * 7. Adobe CMap and CIDFont Files Specification, Version 1.0,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
963 * Adobe Technote 5014, 8th October 1996
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
964 * 8. Adobe CJKV Character Collections and CMaps for CID-Keyed Fonts,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
965 * Adoboe Technote 5094, 8th September, 2001
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
966 * 9. CJKV Information Processing, 2nd Edition,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
967 * O'Reilly, 2002, ISBN 1-56592-224-7
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
968 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
969 * Some of these documents can be found in PDF form on Adobe's web site -
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
970 * http://www.adobe.com
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
971 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
972
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
973 #define PRT_PS_DEFAULT_DPI (72) // Default user space resolution
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
974 #define PRT_PS_DEFAULT_FONTSIZE (10)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
975 #define PRT_PS_DEFAULT_BUFFER_SIZE (80)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
976
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
977 struct prt_mediasize_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
978 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
979 char *name;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
980 float width; // width and height in points for portrait
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
981 float height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
982 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
983
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
984 #define PRT_MEDIASIZE_LEN ARRAY_LENGTH(prt_mediasize)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
985
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
986 static struct prt_mediasize_S prt_mediasize[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
987 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
988 {"A4", 595.0, 842.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
989 {"letter", 612.0, 792.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
990 {"10x14", 720.0, 1008.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
991 {"A3", 842.0, 1191.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
992 {"A5", 420.0, 595.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
993 {"B4", 729.0, 1032.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
994 {"B5", 516.0, 729.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
995 {"executive", 522.0, 756.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
996 {"folio", 595.0, 935.0},
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
997 {"ledger", 1224.0, 792.0}, // Yes, it is wider than taller!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
998 {"legal", 612.0, 1008.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
999 {"quarto", 610.0, 780.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1000 {"statement", 396.0, 612.0},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1001 {"tabloid", 792.0, 1224.0}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1002 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1003
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1004 // PS font names, must be in Roman, Bold, Italic, Bold-Italic order
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1005 struct prt_ps_font_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1006 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1007 int wx;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1008 int uline_offset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1009 int uline_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1010 int bbox_min_y;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1011 int bbox_max_y;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1012 char *(ps_fontname[4]);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1013 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1014
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1015 #define PRT_PS_FONT_ROMAN (0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1016 #define PRT_PS_FONT_BOLD (1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1017 #define PRT_PS_FONT_OBLIQUE (2)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1018 #define PRT_PS_FONT_BOLDOBLIQUE (3)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1019
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1020 // Standard font metrics for Courier family
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1021 static struct prt_ps_font_S prt_ps_courier_font =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1022 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1023 600,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1024 -100, 50,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1025 -250, 805,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1026 {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1027 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1028
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1029 // Generic font metrics for multi-byte fonts
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1030 static struct prt_ps_font_S prt_ps_mb_font =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1031 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1032 1000,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1033 -100, 50,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1034 -250, 805,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1035 {NULL, NULL, NULL, NULL}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1036 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1037
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1038 // Pointer to current font set being used
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1039 static struct prt_ps_font_S* prt_ps_font;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1040
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1041 // Structures to map user named encoding and mapping to PS equivalents for
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1042 // building CID font name
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1043 struct prt_ps_encoding_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1044 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1045 char *encoding;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1046 char *cmap_encoding;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1047 int needs_charset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1048 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1049
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1050 struct prt_ps_charset_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1051 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1052 char *charset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1053 char *cmap_charset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1054 int has_charset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1055 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1056
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1057
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1058 #define CS_JIS_C_1978 (0x01)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1059 #define CS_JIS_X_1983 (0x02)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1060 #define CS_JIS_X_1990 (0x04)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1061 #define CS_NEC (0x08)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1062 #define CS_MSWINDOWS (0x10)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1063 #define CS_CP932 (0x20)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1064 #define CS_KANJITALK6 (0x40)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1065 #define CS_KANJITALK7 (0x80)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1066
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1067 // Japanese encodings and charsets
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1068 static struct prt_ps_encoding_S j_encodings[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1069 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1070 {"iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990|
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1071 CS_NEC)},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1072 {"euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990)},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1073 {"sjis", "RKSJ", (CS_JIS_C_1978|CS_JIS_X_1983|CS_MSWINDOWS|
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1074 CS_KANJITALK6|CS_KANJITALK7)},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1075 {"cp932", "RKSJ", CS_JIS_X_1983},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1076 {"ucs-2", "UCS2", CS_JIS_X_1990},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1077 {"utf-8", "UTF8" , CS_JIS_X_1990}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1078 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1079 static struct prt_ps_charset_S j_charsets[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1080 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1081 {"JIS_C_1978", "78", CS_JIS_C_1978},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1082 {"JIS_X_1983", NULL, CS_JIS_X_1983},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1083 {"JIS_X_1990", "Hojo", CS_JIS_X_1990},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1084 {"NEC", "Ext", CS_NEC},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1085 {"MSWINDOWS", "90ms", CS_MSWINDOWS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1086 {"CP932", "90ms", CS_JIS_X_1983},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1087 {"KANJITALK6", "83pv", CS_KANJITALK6},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1088 {"KANJITALK7", "90pv", CS_KANJITALK7}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1089 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1090
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1091 #define CS_GB_2312_80 (0x01)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1092 #define CS_GBT_12345_90 (0x02)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1093 #define CS_GBK2K (0x04)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1094 #define CS_SC_MAC (0x08)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1095 #define CS_GBT_90_MAC (0x10)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1096 #define CS_GBK (0x20)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1097 #define CS_SC_ISO10646 (0x40)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1098
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1099 // Simplified Chinese encodings and charsets
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1100 static struct prt_ps_encoding_S sc_encodings[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1101 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1102 {"iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90)},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1103 {"gb18030", NULL, CS_GBK2K},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1104 {"euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC|
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1105 CS_GBT_90_MAC)},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1106 {"gbk", "EUC", CS_GBK},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1107 {"ucs-2", "UCS2", CS_SC_ISO10646},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1108 {"utf-8", "UTF8", CS_SC_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1109 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1110 static struct prt_ps_charset_S sc_charsets[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1111 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1112 {"GB_2312-80", "GB", CS_GB_2312_80},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1113 {"GBT_12345-90","GBT", CS_GBT_12345_90},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1114 {"MAC", "GBpc", CS_SC_MAC},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1115 {"GBT-90_MAC", "GBTpc", CS_GBT_90_MAC},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1116 {"GBK", "GBK", CS_GBK},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1117 {"GB18030", "GBK2K", CS_GBK2K},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1118 {"ISO10646", "UniGB", CS_SC_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1119 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1120
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1121 #define CS_CNS_PLANE_1 (0x01)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1122 #define CS_CNS_PLANE_2 (0x02)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1123 #define CS_CNS_PLANE_1_2 (0x04)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1124 #define CS_B5 (0x08)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1125 #define CS_ETEN (0x10)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1126 #define CS_HK_GCCS (0x20)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1127 #define CS_HK_SCS (0x40)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1128 #define CS_HK_SCS_ETEN (0x80)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1129 #define CS_MTHKL (0x100)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1130 #define CS_MTHKS (0x200)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1131 #define CS_DLHKL (0x400)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1132 #define CS_DLHKS (0x800)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1133 #define CS_TC_ISO10646 (0x1000)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1134
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1135 // Traditional Chinese encodings and charsets
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1136 static struct prt_ps_encoding_S tc_encodings[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1137 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1138 {"iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2)},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1139 {"euc-tw", "EUC", CS_CNS_PLANE_1_2},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1140 {"big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS|
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1141 CS_HK_SCS_ETEN|CS_MTHKL|CS_MTHKS|CS_DLHKL|
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1142 CS_DLHKS)},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1143 {"cp950", "B5", CS_B5},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1144 {"ucs-2", "UCS2", CS_TC_ISO10646},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1145 {"utf-8", "UTF8", CS_TC_ISO10646},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1146 {"utf-16", "UTF16", CS_TC_ISO10646},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1147 {"utf-32", "UTF32", CS_TC_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1148 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1149 static struct prt_ps_charset_S tc_charsets[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1150 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1151 {"CNS_1992_1", "CNS1", CS_CNS_PLANE_1},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1152 {"CNS_1992_2", "CNS2", CS_CNS_PLANE_2},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1153 {"CNS_1993", "CNS", CS_CNS_PLANE_1_2},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1154 {"BIG5", NULL, CS_B5},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1155 {"CP950", NULL, CS_B5},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1156 {"ETEN", "ETen", CS_ETEN},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1157 {"HK_GCCS", "HKgccs", CS_HK_GCCS},
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1158 {"SCS", "HKscs", CS_HK_SCS},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1159 {"SCS_ETEN", "ETHK", CS_HK_SCS_ETEN},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1160 {"MTHKL", "HKm471", CS_MTHKL},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1161 {"MTHKS", "HKm314", CS_MTHKS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1162 {"DLHKL", "HKdla", CS_DLHKL},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1163 {"DLHKS", "HKdlb", CS_DLHKS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1164 {"ISO10646", "UniCNS", CS_TC_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1165 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1166
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1167 #define CS_KR_X_1992 (0x01)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1168 #define CS_KR_MAC (0x02)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1169 #define CS_KR_X_1992_MS (0x04)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1170 #define CS_KR_ISO10646 (0x08)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1171
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1172 // Korean encodings and charsets
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1173 static struct prt_ps_encoding_S k_encodings[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1174 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1175 {"iso-2022-kr", NULL, CS_KR_X_1992},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1176 {"euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC)},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1177 {"johab", "Johab", CS_KR_X_1992},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1178 {"cp1361", "Johab", CS_KR_X_1992},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1179 {"uhc", "UHC", CS_KR_X_1992_MS},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1180 {"cp949", "UHC", CS_KR_X_1992_MS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1181 {"ucs-2", "UCS2", CS_KR_ISO10646},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1182 {"utf-8", "UTF8", CS_KR_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1183 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1184 static struct prt_ps_charset_S k_charsets[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1185 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1186 {"KS_X_1992", "KSC", CS_KR_X_1992},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1187 {"CP1361", "KSC", CS_KR_X_1992},
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1188 {"MAC", "KSCpc", CS_KR_MAC},
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1189 {"MSWINDOWS", "KSCms", CS_KR_X_1992_MS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1190 {"CP949", "KSCms", CS_KR_X_1992_MS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1191 {"WANSUNG", "KSCms", CS_KR_X_1992_MS},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1192 {"ISO10646", "UniKS", CS_KR_ISO10646}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1193 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1194
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1195 // Collections of encodings and charsets for multi-byte printing
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1196 struct prt_ps_mbfont_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1197 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1198 int num_encodings;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1199 struct prt_ps_encoding_S *encodings;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1200 int num_charsets;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1201 struct prt_ps_charset_S *charsets;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1202 char *ascii_enc;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1203 char *defcs;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1204 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1205
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1206 static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1207 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1208 {
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1209 ARRAY_LENGTH(j_encodings),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1210 j_encodings,
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1211 ARRAY_LENGTH(j_charsets),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1212 j_charsets,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1213 "jis_roman",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1214 "JIS_X_1983"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1215 },
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1216 {
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1217 ARRAY_LENGTH(sc_encodings),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1218 sc_encodings,
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1219 ARRAY_LENGTH(sc_charsets),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1220 sc_charsets,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1221 "gb_roman",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1222 "GB_2312-80"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1223 },
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1224 {
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1225 ARRAY_LENGTH(tc_encodings),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1226 tc_encodings,
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1227 ARRAY_LENGTH(tc_charsets),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1228 tc_charsets,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1229 "cns_roman",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1230 "BIG5"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1231 },
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1232 {
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1233 ARRAY_LENGTH(k_encodings),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1234 k_encodings,
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1235 ARRAY_LENGTH(k_charsets),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1236 k_charsets,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1237 "ks_roman",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1238 "KS_X_1992"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1239 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1240 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1241
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1242 struct prt_ps_resource_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1243 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1244 char_u name[64];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1245 char_u filename[MAXPATHL + 1];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1246 int type;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1247 char_u title[256];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1248 char_u version[256];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1249 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1250
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1251 // Types of PS resource file currently used
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1252 #define PRT_RESOURCE_TYPE_PROCSET (0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1253 #define PRT_RESOURCE_TYPE_ENCODING (1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1254 #define PRT_RESOURCE_TYPE_CMAP (2)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1255
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1256 // The PS prolog file version number has to match - if the prolog file is
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1257 // updated, increment the number in the file and here. Version checking was
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1258 // added as of VIM 6.2.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1259 // The CID prolog file version number behaves as per PS prolog.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1260 // Table of VIM and prolog versions:
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1261 //
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1262 // VIM Prolog CIDProlog
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1263 // 6.2 1.3
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1264 // 7.0 1.4 1.0
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1265 #define PRT_PROLOG_VERSION ((char_u *)"1.4")
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1266 #define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1267
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1268 // String versions of PS resource types - indexed by constants above so don't
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1269 // re-order!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1270 static char *prt_resource_types[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1271 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1272 "procset",
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1273 "encoding",
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1274 "cmap"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1275 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1276
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1277 // Strings to look for in a PS resource file
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1278 #define PRT_RESOURCE_HEADER "%!PS-Adobe-"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1279 #define PRT_RESOURCE_RESOURCE "Resource-"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1280 #define PRT_RESOURCE_PROCSET "ProcSet"
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1281 #define PRT_RESOURCE_ENCODING "Encoding"
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1282 #define PRT_RESOURCE_CMAP "CMap"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1283
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1284
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1285 // Data for table based DSC comment recognition, easy to extend if VIM needs to
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1286 // read more comments.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1287 #define PRT_DSC_MISC_TYPE (-1)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1288 #define PRT_DSC_TITLE_TYPE (1)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1289 #define PRT_DSC_VERSION_TYPE (2)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1290 #define PRT_DSC_ENDCOMMENTS_TYPE (3)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1291
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1292 #define PRT_DSC_TITLE "%%Title:"
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1293 #define PRT_DSC_VERSION "%%Version:"
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1294 #define PRT_DSC_ENDCOMMENTS "%%EndComments:"
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1295
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1296 struct prt_dsc_comment_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1297 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1298 char *string;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1299 int len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1300 int type;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1301 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1302
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1303 struct prt_dsc_line_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1304 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1305 int type;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1306 char_u *string;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1307 int len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1308 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1309
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1310
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1311 #define SIZEOF_CSTR(s) (sizeof(s) - 1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1312 static struct prt_dsc_comment_S prt_dsc_table[] =
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1313 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1314 {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1315 {PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1316 PRT_DSC_VERSION_TYPE},
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1317 {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1318 PRT_DSC_ENDCOMMENTS_TYPE}
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1319 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1320
7803
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 6759
diff changeset
1321 static void prt_write_file_len(char_u *buffer, int bytes);
37c929c4a073 commit https://github.com/vim/vim/commit/92b8b2d307e34117f146319872010b0ccc9d2713
Christian Brabandt <cb@256bit.org>
parents: 6759
diff changeset
1322 static int prt_next_dsc(struct prt_dsc_line_S *p_dsc_line);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1323
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1324 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1325 * Variables for the output PostScript file.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1326 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1327 static FILE *prt_ps_fd;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1328 static int prt_file_error;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1329 static char_u *prt_ps_file_name = NULL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1330
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1331 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1332 * Various offsets and dimensions in default PostScript user space (points).
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1333 * Used for text positioning calculations
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1334 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1335 static float prt_page_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1336 static float prt_page_height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1337 static float prt_left_margin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1338 static float prt_right_margin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1339 static float prt_top_margin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1340 static float prt_bottom_margin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1341 static float prt_line_height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1342 static float prt_first_line_height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1343 static float prt_char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1344 static float prt_number_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1345 static float prt_bgcol_offset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1346 static float prt_pos_x_moveto = 0.0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1347 static float prt_pos_y_moveto = 0.0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1348
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1349 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1350 * Various control variables used to decide when and how to change the
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1351 * PostScript graphics state.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1352 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1353 static int prt_need_moveto;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1354 static int prt_do_moveto;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1355 static int prt_need_font;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1356 static int prt_font;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1357 static int prt_need_underline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1358 static int prt_underline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1359 static int prt_do_underline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1360 static int prt_need_fgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1361 static int prt_fgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1362 static int prt_need_bgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1363 static int prt_do_bgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1364 static int prt_bgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1365 static int prt_new_bgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1366 static int prt_attribute_change;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1367 static float prt_text_run;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1368 static int prt_page_num;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1369 static int prt_bufsiz;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1370
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1371 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1372 * Variables controlling physical printing.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1373 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1374 static int prt_media;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1375 static int prt_portrait;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1376 static int prt_num_copies;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1377 static int prt_duplex;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1378 static int prt_tumble;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1379 static int prt_collate;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1380
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1381 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1382 * Buffers used when generating PostScript output
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1383 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1384 static char_u prt_line_buffer[257];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1385 static garray_T prt_ps_buffer;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1386
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1387 static int prt_do_conv;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1388 static vimconv_T prt_conv;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1389
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1390 static int prt_out_mbyte;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1391 static int prt_custom_cmap;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1392 static char prt_cmap[80];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1393 static int prt_use_courier;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1394 static int prt_in_ascii;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1395 static int prt_half_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1396 static char *prt_ascii_encoding;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1397 static char_u prt_hexchar[] = "0123456789abcdef";
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1398
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1399 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1400 prt_write_file_raw_len(char_u *buffer, int bytes)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1401 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1402 if (!prt_file_error
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1403 && fwrite(buffer, sizeof(char_u), bytes, prt_ps_fd)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1404 != (size_t)bytes)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1405 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
1406 emsg(_(e_error_writing_to_postscript_output_file));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1407 prt_file_error = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1408 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1409 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1410
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1411 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1412 prt_write_file(char_u *buffer)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1413 {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1414 prt_write_file_len(buffer, (int)STRLEN(buffer));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1415 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1416
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1417 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1418 prt_write_file_len(char_u *buffer, int bytes)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1419 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1420 prt_write_file_raw_len(buffer, bytes);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1421 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1422
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1423 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1424 * Write a string.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1425 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1426 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1427 prt_write_string(char *s)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1428 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1429 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%s", s);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1430 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1431 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1432
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1433 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1434 * Write an int and a space.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1435 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1436 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1437 prt_write_int(int i)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1438 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1439 sprintf((char *)prt_line_buffer, "%d ", i);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1440 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1441 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1443 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1444 * Write a boolean and a space.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1445 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1446 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1447 prt_write_boolean(int b)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1448 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1449 sprintf((char *)prt_line_buffer, "%s ", (b ? "T" : "F"));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1450 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1451 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1452
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1453 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1454 * Write PostScript to re-encode and define the font.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1455 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1456 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1457 prt_def_font(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1458 char *new_name,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1459 char *encoding,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1460 int height,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1461 char *font)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1462 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1463 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1464 "/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1465 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1466 if (prt_out_mbyte)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1467 sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n",
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1468 new_name, height, 500./prt_ps_courier_font.wx, new_name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1469 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1470 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1471 "/%s %d /_%s ffs\n", new_name, height, new_name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1472 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1473 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1474
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1475 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1476 * Write a line to define the CID font.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1477 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1478 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1479 prt_def_cidfont(char *new_name, int height, char *cidfont)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1480 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1481 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1482 "/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1483 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1484 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1485 "/%s %d /_%s ffs\n", new_name, height, new_name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1486 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1487 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1488
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1489 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1490 * Write a line to define a duplicate of a CID font
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1491 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1492 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1493 prt_dup_cidfont(char *original_name, char *new_name)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1494 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1495 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1496 "/%s %s d\n", new_name, original_name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1497 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1498 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1499
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1500 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1501 * Convert a real value into an integer and fractional part as integers, with
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1502 * the fractional part being in the range [0,10^precision). The fractional part
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1503 * is also rounded based on the precision + 1'th fractional digit.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1504 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1505 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1506 prt_real_bits(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1507 double real,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1508 int precision,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1509 int *pinteger,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1510 int *pfraction)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1511 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1512 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1513 int integer;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1514 float fraction;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1515
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1516 integer = (int)real;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1517 fraction = (float)(real - integer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1518 if (real < (double)integer)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1519 fraction = -fraction;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1520 for (i = 0; i < precision; i++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1521 fraction *= 10.0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1522
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1523 *pinteger = integer;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1524 *pfraction = (int)(fraction + 0.5);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1525 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1526
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1527 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1528 * Write a real and a space. Save bytes if real value has no fractional part!
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1529 * We use prt_real_bits() as %f in sprintf uses the locale setting to decide
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1530 * what decimal point character to use, but PS always requires a '.'.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1531 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1532 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1533 prt_write_real(double val, int prec)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1534 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1535 int integer;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1536 int fraction;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1537
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1538 prt_real_bits(val, prec, &integer, &fraction);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1539 // Emit integer part
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1540 sprintf((char *)prt_line_buffer, "%d", integer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1541 prt_write_file(prt_line_buffer);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1542 // Only emit fraction if necessary
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1543 if (fraction != 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1544 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1545 // Remove any trailing zeros
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1546 while ((fraction % 10) == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1547 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1548 prec--;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1549 fraction /= 10;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1550 }
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1551 // Emit fraction left padded with zeros
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1552 sprintf((char *)prt_line_buffer, ".%0*d", prec, fraction);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1553 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1554 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1555 sprintf((char *)prt_line_buffer, " ");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1556 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1557 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1558
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1559 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1560 * Write a line to define a numeric variable.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1561 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1562 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1563 prt_def_var(char *name, double value, int prec)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1564 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1565 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1566 "/%s ", name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1567 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1568 prt_write_real(value, prec);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1569 sprintf((char *)prt_line_buffer, "d\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1570 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1571 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1572
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1573 // Convert size from font space to user space at current font scale
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1574 #define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1575
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1576 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1577 prt_flush_buffer(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1578 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1579 if (prt_ps_buffer.ga_len <= 0)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1580 return;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1581
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1582 // Any background color must be drawn first
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1583 if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE))
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1584 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1585 int r, g, b;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1586
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1587 if (prt_do_moveto)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1588 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1589 prt_write_real(prt_pos_x_moveto, 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1590 prt_write_real(prt_pos_y_moveto, 2);
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1591 prt_write_string("m\n");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1592 prt_do_moveto = FALSE;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1593 }
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1594
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1595 // Size of rect of background color on which text is printed
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1596 prt_write_real(prt_text_run, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1597 prt_write_real(prt_line_height, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1598
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1599 // Lastly add the color of the background
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1600 r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1601 g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1602 b = prt_new_bgcol & 0xff;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1603 prt_write_real(r / 255.0, 3);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1604 prt_write_real(g / 255.0, 3);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1605 prt_write_real(b / 255.0, 3);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1606 prt_write_string("bg\n");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1607 }
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1608 // Draw underlines before the text as it makes it slightly easier to
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1609 // find the starting point.
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1610 if (prt_do_underline)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1611 {
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1612 if (prt_do_moveto)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1613 {
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1614 prt_write_real(prt_pos_x_moveto, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1615 prt_write_real(prt_pos_y_moveto, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1616 prt_write_string("m\n");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1617 prt_do_moveto = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1618 }
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1619
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1620 // Underline length of text run
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1621 prt_write_real(prt_text_run, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1622 prt_write_string("ul\n");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1623 }
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1624 // Draw the text
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1625 if (prt_out_mbyte)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1626 prt_write_string("<");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1627 else
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1628 prt_write_string("(");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1629 prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1630 if (prt_out_mbyte)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1631 prt_write_string(">");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1632 else
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1633 prt_write_string(")");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1634 // Add a moveto if need be and use the appropriate show procedure
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1635 if (prt_do_moveto)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1636 {
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1637 prt_write_real(prt_pos_x_moveto, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1638 prt_write_real(prt_pos_y_moveto, 2);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1639 // moveto and a show
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1640 prt_write_string("ms\n");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1641 prt_do_moveto = FALSE;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1642 }
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1643 else // Simple show
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1644 prt_write_string("s\n");
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1645
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1646 ga_clear(&prt_ps_buffer);
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
1647 ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1648 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1649
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1650
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1651 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1652 prt_resource_name(char_u *filename, void *cookie)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1653 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1654 char_u *resource_filename = cookie;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1655
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1656 if (STRLEN(filename) >= MAXPATHL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1657 *resource_filename = NUL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1658 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1659 STRCPY(resource_filename, filename);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1660 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1661
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1662 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1663 prt_find_resource(char *name, struct prt_ps_resource_S *resource)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1664 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1665 char_u *buffer;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1666 int retval;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1667
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1668 buffer = alloc(MAXPATHL + 1);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1669 if (buffer == NULL)
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1670 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1671
2768
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2445
diff changeset
1672 vim_strncpy(resource->name, (char_u *)name, 63);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1673 // Look for named resource file in runtimepath
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1674 STRCPY(buffer, "print");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1675 add_pathsep(buffer);
2768
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2445
diff changeset
1676 vim_strcat(buffer, (char_u *)name, MAXPATHL);
c5e47b752f07 updated for version 7.3.160
Bram Moolenaar <bram@vim.org>
parents: 2445
diff changeset
1677 vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1678 resource->filename[0] = NUL;
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
1679 retval = (do_in_runtimepath(buffer, 0, prt_resource_name,
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1680 resource->filename)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1681 && resource->filename[0] != NUL);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1682 vim_free(buffer);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
1683 return retval;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1684 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1685
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1686 // PS CR and LF characters have platform independent values
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1687 #define PSLF (0x0a)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1688 #define PSCR (0x0d)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1689
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1690 // Static buffer to read initial comments in a resource file, some can have a
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1691 // couple of KB of comments!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1692 #define PRT_FILE_BUFFER_LEN (2048)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1693 struct prt_resfile_buffer_S
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1694 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1695 char_u buffer[PRT_FILE_BUFFER_LEN];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1696 int len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1697 int line_start;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1698 int line_end;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1699 };
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1700
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1701 static struct prt_resfile_buffer_S prt_resfile;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1702
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1703 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1704 prt_resfile_next_line(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1705 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1706 int idx;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1707
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1708 // Move to start of next line and then find end of line
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1709 idx = prt_resfile.line_end + 1;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1710 while (idx < prt_resfile.len)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1711 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1712 if (prt_resfile.buffer[idx] != PSLF && prt_resfile.buffer[idx] != PSCR)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1713 break;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1714 idx++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1715 }
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1716 prt_resfile.line_start = idx;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1717
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1718 while (idx < prt_resfile.len)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1719 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1720 if (prt_resfile.buffer[idx] == PSLF || prt_resfile.buffer[idx] == PSCR)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1721 break;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1722 idx++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1723 }
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1724 prt_resfile.line_end = idx;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1725
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1726 return (idx < prt_resfile.len);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1727 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1728
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1729 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1730 prt_resfile_strncmp(int offset, char *string, int len)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1731 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1732 // Force not equal if string is longer than remainder of line
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1733 if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset)))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1734 return 1;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1735
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1736 return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset],
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1737 string, len);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1738 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1739
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1740 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1741 prt_resfile_skip_nonws(int offset)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1742 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1743 int idx;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1744
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1745 idx = prt_resfile.line_start + offset;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1746 while (idx < prt_resfile.line_end)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1747 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1748 if (isspace(prt_resfile.buffer[idx]))
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1749 return idx - prt_resfile.line_start;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1750 idx++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1751 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1752 return -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1753 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1754
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1755 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1756 prt_resfile_skip_ws(int offset)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1757 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1758 int idx;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1759
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1760 idx = prt_resfile.line_start + offset;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1761 while (idx < prt_resfile.line_end)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1762 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1763 if (!isspace(prt_resfile.buffer[idx]))
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1764 return idx - prt_resfile.line_start;
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
1765 idx++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1766 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1767 return -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1768 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1769
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1770 // prt_next_dsc() - returns detail on next DSC comment line found. Returns true
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1771 // if a DSC comment is found, else false
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1772 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1773 prt_next_dsc(struct prt_dsc_line_S *p_dsc_line)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1774 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1775 int comment;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1776 int offset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1777
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1778 // Move to start of next line
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1779 if (!prt_resfile_next_line())
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1780 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1781
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1782 // DSC comments always start %%
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1783 if (prt_resfile_strncmp(0, "%%", 2) != 0)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1784 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1785
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1786 // Find type of DSC comment
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1787 for (comment = 0; comment < (int)ARRAY_LENGTH(prt_dsc_table); comment++)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1788 if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1789 prt_dsc_table[comment].len) == 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1790 break;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1791
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1792 if (comment != ARRAY_LENGTH(prt_dsc_table))
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1793 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1794 // Return type of comment
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1795 p_dsc_line->type = prt_dsc_table[comment].type;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1796 offset = prt_dsc_table[comment].len;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1797 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1798 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1799 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1800 // Unrecognised DSC comment, skip to ws after comment leader
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1801 p_dsc_line->type = PRT_DSC_MISC_TYPE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1802 offset = prt_resfile_skip_nonws(0);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1803 if (offset == -1)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1804 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1805 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1806
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1807 // Skip ws to comment value
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1808 offset = prt_resfile_skip_ws(offset);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1809 if (offset == -1)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1810 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1811
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1812 p_dsc_line->string = &prt_resfile.buffer[prt_resfile.line_start + offset];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1813 p_dsc_line->len = prt_resfile.line_end - (prt_resfile.line_start + offset);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1814
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1815 return TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1816 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1817
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1818 /*
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1819 * Improved hand crafted parser to get the type, title, and version number of a
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1820 * PS resource file so the file details can be added to the DSC header comments.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1821 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1822 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1823 prt_open_resource(struct prt_ps_resource_S *resource)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1824 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1825 int offset;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1826 int seen_all;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1827 int seen_title;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1828 int seen_version;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1829 FILE *fd_resource;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1830 struct prt_dsc_line_S dsc_line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1831
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1832 fd_resource = mch_fopen((char *)resource->filename, READBIN);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1833 if (fd_resource == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1834 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1835 semsg(_(e_cant_open_file_str_3), resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1836 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1837 }
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 18798
diff changeset
1838 CLEAR_FIELD(prt_resfile.buffer);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1839
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1840 // Parse first line to ensure valid resource file
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1841 prt_resfile.len = (int)fread((char *)prt_resfile.buffer, sizeof(char_u),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1842 PRT_FILE_BUFFER_LEN, fd_resource);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1843 if (ferror(fd_resource))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1844 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
1845 semsg(_(e_cant_read_postscript_resource_file_str),
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1846 resource->filename);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1847 fclose(fd_resource);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1848 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1849 }
2445
04dae202d316 Fixes for coverity warnings.
Bram Moolenaar <bram@vim.org>
parents: 2250
diff changeset
1850 fclose(fd_resource);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1851
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1852 prt_resfile.line_end = -1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1853 prt_resfile.line_start = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1854 if (!prt_resfile_next_line())
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1855 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1856
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1857 offset = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1858
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1859 if (prt_resfile_strncmp(offset, PRT_RESOURCE_HEADER,
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1860 (int)STRLEN(PRT_RESOURCE_HEADER)) != 0)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1861 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1862 semsg(_(e_file_str_is_not_postscript_resource_file),
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1863 resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1864 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1865 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1866
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1867 // Skip over any version numbers and following ws
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1868 offset += (int)STRLEN(PRT_RESOURCE_HEADER);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1869 offset = prt_resfile_skip_nonws(offset);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1870 if (offset == -1)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1871 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1872 offset = prt_resfile_skip_ws(offset);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1873 if (offset == -1)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1874 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1875
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1876 if (prt_resfile_strncmp(offset, PRT_RESOURCE_RESOURCE,
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1877 (int)STRLEN(PRT_RESOURCE_RESOURCE)) != 0)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1878 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1879 semsg(_(e_file_str_is_not_supported_postscript_resource_file),
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1880 resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1881 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1882 }
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1883 offset += (int)STRLEN(PRT_RESOURCE_RESOURCE);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1884
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1885 // Decide type of resource in the file
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1886 if (prt_resfile_strncmp(offset, PRT_RESOURCE_PROCSET,
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1887 (int)STRLEN(PRT_RESOURCE_PROCSET)) == 0)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1888 resource->type = PRT_RESOURCE_TYPE_PROCSET;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1889 else if (prt_resfile_strncmp(offset, PRT_RESOURCE_ENCODING,
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1890 (int)STRLEN(PRT_RESOURCE_ENCODING)) == 0)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1891 resource->type = PRT_RESOURCE_TYPE_ENCODING;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1892 else if (prt_resfile_strncmp(offset, PRT_RESOURCE_CMAP,
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
1893 (int)STRLEN(PRT_RESOURCE_CMAP)) == 0)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1894 resource->type = PRT_RESOURCE_TYPE_CMAP;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1895 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1896 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1897 semsg(_(e_file_str_is_not_supported_postscript_resource_file),
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1898 resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1899 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1900 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1901
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1902 // Look for title and version of resource
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1903 resource->title[0] = '\0';
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1904 resource->version[0] = '\0';
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1905 seen_title = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1906 seen_version = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1907 seen_all = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1908 while (!seen_all && prt_next_dsc(&dsc_line))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1909 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1910 switch (dsc_line.type)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1911 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1912 case PRT_DSC_TITLE_TYPE:
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1913 vim_strncpy(resource->title, dsc_line.string, dsc_line.len);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1914 seen_title = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1915 if (seen_version)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1916 seen_all = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1917 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1918
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1919 case PRT_DSC_VERSION_TYPE:
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1920 vim_strncpy(resource->version, dsc_line.string, dsc_line.len);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1921 seen_version = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1922 if (seen_title)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1923 seen_all = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1924 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1925
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1926 case PRT_DSC_ENDCOMMENTS_TYPE:
25852
336e2d9924e6 patch 8.2.3460: some type casts are not needed
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
1927 // Won't find title or resource after this comment, stop searching
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1928 seen_all = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1929 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1930
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1931 case PRT_DSC_MISC_TYPE:
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1932 // Not interested in whatever comment this line had
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1933 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
1934 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1935 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1936
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1937 if (!seen_title || !seen_version)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1938 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1939 semsg(_(e_file_str_is_not_supported_postscript_resource_file),
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1940 resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1941 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1942 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1943
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1944 return TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1945 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1946
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1947 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1948 prt_check_resource(struct prt_ps_resource_S *resource, char_u *version)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1949 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1950 // Version number m.n should match, the revision number does not matter
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1951 if (STRNCMP(resource->version, version, STRLEN(version)))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1952 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
1953 semsg(_(e_str_resource_file_has_wrong_version),
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1954 resource->name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1955 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1956 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1957
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1958 // Other checks to be added as needed
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1959 return TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1960 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1961
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1962 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1963 prt_dsc_start(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1964 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1965 prt_write_string("%!PS-Adobe-3.0\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1966 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1967
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1968 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1969 prt_dsc_noarg(char *comment)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1970 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1971 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1972 "%%%%%s\n", comment);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1973 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1974 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1975
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1976 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1977 prt_dsc_textline(char *comment, char *text)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1978 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1979 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1980 "%%%%%s: %s\n", comment, text);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1981 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1982 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1983
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1984 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1985 prt_dsc_text(char *comment, char *text)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1986 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1987 // TODO - should scan 'text' for any chars needing escaping!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1988 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1989 "%%%%%s: (%s)\n", comment, text);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1990 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1991 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1992
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1993 #define prt_dsc_atend(c) prt_dsc_text((c), "atend")
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1994
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1995 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
1996 prt_dsc_ints(char *comment, int count, int *ints)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1997 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1998 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
1999
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2000 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2001 "%%%%%s:", comment);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2002 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2003
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2004 for (i = 0; i < count; i++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2005 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2006 sprintf((char *)prt_line_buffer, " %d", ints[i]);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2007 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2008 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2009
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2010 prt_write_string("\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2011 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2012
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2013 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2014 prt_dsc_resources(
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2015 char *comment, // if NULL add to previous
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2016 char *type,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2017 char *string)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2018 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2019 if (comment != NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2020 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2021 "%%%%%s: %s", comment, type);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2022 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2023 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2024 "%%%%+ %s", type);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2025 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2026
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2027 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2028 " %s\n", string);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2029 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2030 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2031
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2032 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2033 prt_dsc_font_resource(char *resource, struct prt_ps_font_S *ps_font)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2034 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2035 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2036
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2037 prt_dsc_resources(resource, "font",
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2038 ps_font->ps_fontname[PRT_PS_FONT_ROMAN]);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2039 for (i = PRT_PS_FONT_BOLD ; i <= PRT_PS_FONT_BOLDOBLIQUE ; i++)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2040 if (ps_font->ps_fontname[i] != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2041 prt_dsc_resources(NULL, "font", ps_font->ps_fontname[i]);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2042 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2043
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2044 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2045 prt_dsc_requirements(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2046 int duplex,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2047 int tumble,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2048 int collate,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2049 int color,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2050 int num_copies)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2051 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2052 // Only output the comment if we need to.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2053 // Note: tumble is ignored if we are not duplexing
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2054 if (!(duplex || collate || color || (num_copies > 1)))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2055 return;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2056
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2057 sprintf((char *)prt_line_buffer, "%%%%Requirements:");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2058 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2059
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2060 if (duplex)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2061 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2062 prt_write_string(" duplex");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2063 if (tumble)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2064 prt_write_string("(tumble)");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2065 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2066 if (collate)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2067 prt_write_string(" collate");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2068 if (color)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2069 prt_write_string(" color");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2070 if (num_copies > 1)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2071 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2072 prt_write_string(" numcopies(");
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2073 // Note: no space wanted so don't use prt_write_int()
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2074 sprintf((char *)prt_line_buffer, "%d", num_copies);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2075 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2076 prt_write_string(")");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2077 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2078 prt_write_string("\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2079 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2080
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2081 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2082 prt_dsc_docmedia(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2083 char *paper_name,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2084 double width,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2085 double height,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2086 double weight,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2087 char *colour,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2088 char *type)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2089 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2090 vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2091 "%%%%DocumentMedia: %s ", paper_name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2092 prt_write_file(prt_line_buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2093 prt_write_real(width, 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2094 prt_write_real(height, 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2095 prt_write_real(weight, 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2096 if (colour == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2097 prt_write_string("()");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2098 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2099 prt_write_string(colour);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2100 prt_write_string(" ");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2101 if (type == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2102 prt_write_string("()");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2103 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2104 prt_write_string(type);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2105 prt_write_string("\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2106 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2107
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2108 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2109 mch_print_cleanup(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2110 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2111 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2112 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2113 int i;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2114
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2115 // Free off all CID font names created, but first clear duplicate
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2116 // pointers to the same string (when the same font is used for more than
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2117 // one style).
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2118 for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2119 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2120 if (prt_ps_mb_font.ps_fontname[i] != NULL)
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
2121 VIM_CLEAR(prt_ps_mb_font.ps_fontname[i]);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2122 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2123 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2124
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2125 if (prt_do_conv)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2126 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2127 convert_setup(&prt_conv, NULL, NULL);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2128 prt_do_conv = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2129 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2130 if (prt_ps_fd != NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2131 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2132 fclose(prt_ps_fd);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2133 prt_ps_fd = NULL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2134 prt_file_error = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2135 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2136 if (prt_ps_file_name != NULL)
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
2137 VIM_CLEAR(prt_ps_file_name);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2138 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2139
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2140 static float
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2141 to_device_units(int idx, double physsize, int def_number)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2142 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2143 float ret;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2144 int u;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2145 int nr;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2146
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2147 u = prt_get_unit(idx);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2148 if (u == PRT_UNIT_NONE)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2149 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2150 u = PRT_UNIT_PERC;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2151 nr = def_number;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2152 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2153 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2154 nr = printer_opts[idx].number;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2155
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2156 switch (u)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2157 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2158 case PRT_UNIT_INCH:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2159 ret = (float)(nr * PRT_PS_DEFAULT_DPI);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2160 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2161 case PRT_UNIT_MM:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2162 ret = (float)(nr * PRT_PS_DEFAULT_DPI) / (float)25.4;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2163 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2164 case PRT_UNIT_POINT:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2165 ret = (float)nr;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2166 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2167 case PRT_UNIT_PERC:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2168 default:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2169 ret = (float)(physsize * nr) / 100;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2170 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2171 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2172
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2173 return ret;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2174 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2175
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2176 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2177 * Calculate margins for given width and height from printoptions settings.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2178 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2179 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2180 prt_page_margins(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2181 double width,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2182 double height,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2183 double *left,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2184 double *right,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2185 double *top,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2186 double *bottom)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2187 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2188 *left = to_device_units(OPT_PRINT_LEFT, width, 10);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2189 *right = width - to_device_units(OPT_PRINT_RIGHT, width, 5);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2190 *top = height - to_device_units(OPT_PRINT_TOP, height, 5);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2191 *bottom = to_device_units(OPT_PRINT_BOT, height, 5);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2192 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2193
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2194 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2195 prt_font_metrics(int font_scale)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2196 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2197 prt_line_height = (float)font_scale;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2198 prt_char_width = (float)PRT_PS_FONT_TO_USER(font_scale, prt_ps_font->wx);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2199 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2200
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2201
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2202 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2203 prt_get_cpl(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2204 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2205 if (prt_use_number())
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2206 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2207 prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2208 // If we are outputting multi-byte characters then line numbers will be
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2209 // printed with half width characters
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2210 if (prt_out_mbyte)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2211 prt_number_width /= 2;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2212 prt_left_margin += prt_number_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2213 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2214 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2215 prt_number_width = 0.0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2216
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2217 return (int)((prt_right_margin - prt_left_margin) / prt_char_width);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2218 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2219
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2220 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2221 prt_build_cid_fontname(int font, char_u *name, int name_len)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2222 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2223 char *fontname;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2224
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16621
diff changeset
2225 fontname = alloc(name_len + 1);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2226 if (fontname == NULL)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2227 return FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2228 vim_strncpy((char_u *)fontname, name, name_len);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2229 prt_ps_mb_font.ps_fontname[font] = fontname;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2230
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2231 return TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2232 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2233
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2234 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2235 * Get number of lines of text that fit on a page (excluding the header).
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2236 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2237 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2238 prt_get_lpp(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2239 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2240 int lpp;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2241
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2242 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2243 * Calculate offset to lower left corner of background rect based on actual
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2244 * font height (based on its bounding box) and the line height, handling the
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2245 * case where the font height can exceed the line height.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2246 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2247 prt_bgcol_offset = (float)PRT_PS_FONT_TO_USER(prt_line_height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2248 prt_ps_font->bbox_min_y);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2249 if ((prt_ps_font->bbox_max_y - prt_ps_font->bbox_min_y) < 1000.0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2250 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2251 prt_bgcol_offset -= (float)PRT_PS_FONT_TO_USER(prt_line_height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2252 (1000.0 - (prt_ps_font->bbox_max_y -
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2253 prt_ps_font->bbox_min_y)) / 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2254 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2255
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2256 // Get height for topmost line based on background rect offset.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2257 prt_first_line_height = prt_line_height + prt_bgcol_offset;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2258
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2259 // Calculate lpp
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2260 lpp = (int)((prt_top_margin - prt_bottom_margin) / prt_line_height);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2261
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2262 // Adjust top margin if there is a header
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2263 prt_top_margin -= prt_line_height * prt_header_height();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2264
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2265 return lpp - prt_header_height();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2266 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2267
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2268 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2269 prt_match_encoding(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2270 char *p_encoding,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2271 struct prt_ps_mbfont_S *p_cmap,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2272 struct prt_ps_encoding_S **pp_mbenc)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2273 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2274 int mbenc;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2275 int enc_len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2276 struct prt_ps_encoding_S *p_mbenc;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2277
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2278 *pp_mbenc = NULL;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2279 // Look for recognised encoding
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
2280 enc_len = (int)STRLEN(p_encoding);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2281 p_mbenc = p_cmap->encodings;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2282 for (mbenc = 0; mbenc < p_cmap->num_encodings; mbenc++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2283 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2284 if (STRNICMP(p_mbenc->encoding, p_encoding, enc_len) == 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2285 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2286 *pp_mbenc = p_mbenc;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2287 return TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2288 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2289 p_mbenc++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2290 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2291 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2292 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2293
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2294 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2295 prt_match_charset(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2296 char *p_charset,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2297 struct prt_ps_mbfont_S *p_cmap,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2298 struct prt_ps_charset_S **pp_mbchar)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2299 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2300 int mbchar;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2301 int char_len;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2302 struct prt_ps_charset_S *p_mbchar;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2303
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2304 // Look for recognised character set, using default if one is not given
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2305 if (*p_charset == NUL)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2306 p_charset = p_cmap->defcs;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
2307 char_len = (int)STRLEN(p_charset);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2308 p_mbchar = p_cmap->charsets;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2309 for (mbchar = 0; mbchar < p_cmap->num_charsets; mbchar++)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2310 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2311 if (STRNICMP(p_mbchar->charset, p_charset, char_len) == 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2312 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2313 *pp_mbchar = p_mbchar;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2314 return TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2315 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2316 p_mbchar++;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2317 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2318 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2319 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2320
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2321 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2322 mch_print_init(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2323 prt_settings_T *psettings,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2324 char_u *jobname,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2325 int forceit UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2326 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2327 int i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2328 char *paper_name;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2329 int paper_strlen;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2330 int fontsize;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2331 char_u *p;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2332 double left;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2333 double right;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2334 double top;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2335 double bottom;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2336 int props;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2337 int cmap = 0;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2338 char_u *p_encoding;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2339 struct prt_ps_encoding_S *p_mbenc;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2340 struct prt_ps_encoding_S *p_mbenc_first;
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 864
diff changeset
2341 struct prt_ps_charset_S *p_mbchar = NULL;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2342
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2343 #if 0
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2344 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2345 * TODO:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2346 * If "forceit" is false: pop up a dialog to select:
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2347 * - printer name
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2348 * - copies
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2349 * - collated/uncollated
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2350 * - duplex off/long side/short side
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2351 * - paper size
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2352 * - portrait/landscape
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2353 * - font size
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2354 *
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2355 * If "forceit" is true: use the default printer and settings
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2356 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2357 if (forceit)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2358 s_pd.Flags |= PD_RETURNDEFAULT;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2359 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2360
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2361 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2362 * Set up font and encoding.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2363 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2364 p_encoding = enc_skip(p_penc);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2365 if (*p_encoding == NUL)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2366 p_encoding = enc_skip(p_enc);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2367
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2368 // Look for a multi-byte font that matches the encoding and character set.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2369 // Only look if multi-byte character set is defined, or using multi-byte
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2370 // encoding other than Unicode. This is because a Unicode encoding does not
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2371 // uniquely identify a CJK character set to use.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2372 p_mbenc = NULL;
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 744
diff changeset
2373 props = enc_canon_props(p_encoding);
864
bc620d6bdf06 updated for version 7.0g03
vimboss
parents: 856
diff changeset
2374 if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE)))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 744
diff changeset
2375 {
6759
b019669eee53 patch 7.4.701
Bram Moolenaar <bram@vim.org>
parents: 6745
diff changeset
2376 int cmap_first = 0;
6745
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2377
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2378 p_mbenc_first = NULL;
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
2379 for (cmap = 0; cmap < (int)ARRAY_LENGTH(prt_ps_mbfonts); cmap++)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2380 if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2381 &p_mbenc))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2382 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2383 if (p_mbenc_first == NULL)
6745
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2384 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2385 p_mbenc_first = p_mbenc;
6745
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2386 cmap_first = cmap;
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2387 }
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2388 if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap],
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2389 &p_mbchar))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2390 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2391 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2392
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2393 // Use first encoding matched if no charset matched
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2394 if (p_mbchar == NULL && p_mbenc_first != NULL)
6745
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2395 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2396 p_mbenc = p_mbenc_first;
6745
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2397 cmap = cmap_first;
7f9a158cf1d9 patch 7.4.695
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2398 }
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 744
diff changeset
2399 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2400
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2401 prt_out_mbyte = (p_mbenc != NULL);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2402 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2403 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2404 // Build CMap name - will be same for all multi-byte fonts used
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2405 prt_cmap[0] = NUL;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2406
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2407 prt_custom_cmap = (p_mbchar == NULL);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2408 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2409 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2410 // Check encoding and character set are compatible
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2411 if ((p_mbenc->needs_charset & p_mbchar->has_charset) == 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2412 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
2413 emsg(_(e_incompatible_multi_byte_encoding_and_character_set));
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2414 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2415 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2416
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2417 // Add charset name if not empty
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2418 if (p_mbchar->cmap_charset != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2419 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2420 vim_strncpy((char_u *)prt_cmap,
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2421 (char_u *)p_mbchar->cmap_charset, sizeof(prt_cmap) - 3);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2422 STRCAT(prt_cmap, "-");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2423 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2424 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2425 else
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2426 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2427 // Add custom CMap character set name
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2428 if (*p_pmcs == NUL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2429 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
2430 emsg(_(e_printmbcharset_cannot_be_empty_with_multi_byte_encoding));
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2431 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2432 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2433 vim_strncpy((char_u *)prt_cmap, p_pmcs, sizeof(prt_cmap) - 3);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2434 STRCAT(prt_cmap, "-");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2435 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2436
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2437 // CMap name ends with (optional) encoding name and -H for horizontal
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2438 if (p_mbenc->cmap_encoding != NULL && STRLEN(prt_cmap)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2439 + STRLEN(p_mbenc->cmap_encoding) + 3 < sizeof(prt_cmap))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2440 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2441 STRCAT(prt_cmap, p_mbenc->cmap_encoding);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2442 STRCAT(prt_cmap, "-");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2443 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2444 STRCAT(prt_cmap, "H");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2445
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2446 if (!mbfont_opts[OPT_MBFONT_REGULAR].present)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2447 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
2448 emsg(_(e_no_default_font_specified_for_multi_byte_printing));
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2449 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2450 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2451
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2452 // Derive CID font names with fallbacks if not defined
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2453 if (!prt_build_cid_fontname(PRT_PS_FONT_ROMAN,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2454 mbfont_opts[OPT_MBFONT_REGULAR].string,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2455 mbfont_opts[OPT_MBFONT_REGULAR].strlen))
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2456 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2457 if (mbfont_opts[OPT_MBFONT_BOLD].present)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2458 if (!prt_build_cid_fontname(PRT_PS_FONT_BOLD,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2459 mbfont_opts[OPT_MBFONT_BOLD].string,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2460 mbfont_opts[OPT_MBFONT_BOLD].strlen))
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2461 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2462 if (mbfont_opts[OPT_MBFONT_OBLIQUE].present)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2463 if (!prt_build_cid_fontname(PRT_PS_FONT_OBLIQUE,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2464 mbfont_opts[OPT_MBFONT_OBLIQUE].string,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2465 mbfont_opts[OPT_MBFONT_OBLIQUE].strlen))
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2466 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2467 if (mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].present)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2468 if (!prt_build_cid_fontname(PRT_PS_FONT_BOLDOBLIQUE,
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2469 mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2470 mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2471 return FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2472
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2473 // Check if need to use Courier for ASCII code range, and if so pick up
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2474 // the encoding to use
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2475 prt_use_courier = mbfont_opts[OPT_MBFONT_USECOURIER].present &&
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2476 (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y');
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2477 if (prt_use_courier)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2478 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2479 // Use national ASCII variant unless ASCII wanted
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2480 if (mbfont_opts[OPT_MBFONT_ASCII].present &&
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2481 (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_ASCII].string[0]) == 'y'))
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2482 prt_ascii_encoding = "ascii";
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2483 else
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2484 prt_ascii_encoding = prt_ps_mbfonts[cmap].ascii_enc;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2485 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2486
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2487 prt_ps_font = &prt_ps_mb_font;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2488 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2489 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2490 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2491 prt_use_courier = FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2492 prt_ps_font = &prt_ps_courier_font;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2493 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2494
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2495 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2496 * Find the size of the paper and set the margins.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2497 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2498 prt_portrait = (!printer_opts[OPT_PRINT_PORTRAIT].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2499 || TOLOWER_ASC(printer_opts[OPT_PRINT_PORTRAIT].string[0]) == 'y');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2500 if (printer_opts[OPT_PRINT_PAPER].present)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2501 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2502 paper_name = (char *)printer_opts[OPT_PRINT_PAPER].string;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2503 paper_strlen = printer_opts[OPT_PRINT_PAPER].strlen;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2504 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2505 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2506 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2507 paper_name = "A4";
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2508 paper_strlen = 2;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2509 }
1880
e5602d92da8c updated for version 7.2-177
vimboss
parents: 1504
diff changeset
2510 for (i = 0; i < (int)PRT_MEDIASIZE_LEN; ++i)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2511 if (STRLEN(prt_mediasize[i].name) == (unsigned)paper_strlen
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2512 && STRNICMP(prt_mediasize[i].name, paper_name,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2513 paper_strlen) == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2514 break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2515 if (i == PRT_MEDIASIZE_LEN)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2516 i = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2517 prt_media = i;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2518
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2519 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2520 * Set PS pagesize based on media dimensions and print orientation.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2521 * Note: Media and page sizes have defined meanings in PostScript and should
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2522 * be kept distinct. Media is the paper (or transparency, or ...) that is
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2523 * printed on, whereas the page size is the area that the PostScript
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2524 * interpreter renders into.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2525 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2526 if (prt_portrait)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2527 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2528 prt_page_width = prt_mediasize[i].width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2529 prt_page_height = prt_mediasize[i].height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2530 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2531 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2532 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2533 prt_page_width = prt_mediasize[i].height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2534 prt_page_height = prt_mediasize[i].width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2535 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2536
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2537 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2538 * Set PS page margins based on the PS pagesize, not the mediasize - this
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2539 * needs to be done before the cpl and lpp are calculated.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2540 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2541 prt_page_margins(prt_page_width, prt_page_height, &left, &right, &top,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2542 &bottom);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2543 prt_left_margin = (float)left;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2544 prt_right_margin = (float)right;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2545 prt_top_margin = (float)top;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2546 prt_bottom_margin = (float)bottom;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2547
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2548 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2549 * Set up the font size.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2550 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2551 fontsize = PRT_PS_DEFAULT_FONTSIZE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2552 for (p = p_pfn; (p = vim_strchr(p, ':')) != NULL; ++p)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2553 if (p[1] == 'h' && VIM_ISDIGIT(p[2]))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2554 fontsize = atoi((char *)p + 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2555 prt_font_metrics(fontsize);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2556
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2557 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2558 * Return the number of characters per line, and lines per page for the
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2559 * generic print code.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2560 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2561 psettings->chars_per_line = prt_get_cpl();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2562 psettings->lines_per_page = prt_get_lpp();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2563
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2564 // Catch margin settings that leave no space for output!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2565 if (psettings->chars_per_line <= 0 || psettings->lines_per_page <= 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2566 return FAIL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2567
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2568 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2569 * Sort out the number of copies to be printed. PS by default will do
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2570 * uncollated copies for you, so once we know how many uncollated copies are
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2571 * wanted cache it away and lie to the generic code that we only want one
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2572 * uncollated copy.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2573 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2574 psettings->n_collated_copies = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2575 psettings->n_uncollated_copies = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2576 prt_num_copies = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2577 prt_collate = (!printer_opts[OPT_PRINT_COLLATE].present
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2578 || TOLOWER_ASC(printer_opts[OPT_PRINT_COLLATE].string[0]) == 'y');
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2579 if (prt_collate)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2580 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2581 // TODO: Get number of collated copies wanted.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2582 psettings->n_collated_copies = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2583 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2584 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2585 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2586 // TODO: Get number of uncollated copies wanted and update the cached
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2587 // count.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2588 prt_num_copies = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2589 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2590
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2591 psettings->jobname = jobname;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2592
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2593 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2594 * Set up printer duplex and tumble based on Duplex option setting - default
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2595 * is long sided duplex printing (i.e. no tumble).
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2596 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2597 prt_duplex = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2598 prt_tumble = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2599 psettings->duplex = 1;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2600 if (printer_opts[OPT_PRINT_DUPLEX].present)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2601 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2602 if (STRNICMP(printer_opts[OPT_PRINT_DUPLEX].string, "off", 3) == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2603 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2604 prt_duplex = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2605 psettings->duplex = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2606 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2607 else if (STRNICMP(printer_opts[OPT_PRINT_DUPLEX].string, "short", 5)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2608 == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2609 prt_tumble = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2610 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2611
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2612 // For now user abort not supported
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2613 psettings->user_abort = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2614
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2615 // If the user didn't specify a file name, use a temp file.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2616 if (psettings->outfile == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2617 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6404
diff changeset
2618 prt_ps_file_name = vim_tempname('p', TRUE);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2619 if (prt_ps_file_name == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2620 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25852
diff changeset
2621 emsg(_(e_cant_get_temp_file_name));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2622 return FAIL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2623 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2624 prt_ps_fd = mch_fopen((char *)prt_ps_file_name, WRITEBIN);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2625 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2626 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2627 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2628 p = expand_env_save(psettings->outfile);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2629 if (p != NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2630 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2631 prt_ps_fd = mch_fopen((char *)p, WRITEBIN);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2632 vim_free(p);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2633 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2634 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2635 if (prt_ps_fd == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2636 {
26909
aa65d1808bd0 patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
2637 emsg(_(e_cant_open_postscript_output_file));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2638 mch_print_cleanup();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2639 return FAIL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2640 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2641
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2642 prt_bufsiz = psettings->chars_per_line;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2643 if (prt_out_mbyte)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2644 prt_bufsiz *= 2;
27028
c9474ae175f4 patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
2645 ga_init2(&prt_ps_buffer, sizeof(char), prt_bufsiz);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2646
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2647 prt_page_num = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2648
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2649 prt_attribute_change = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2650 prt_need_moveto = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2651 prt_need_font = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2652 prt_need_fgcol = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2653 prt_need_bgcol = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2654 prt_need_underline = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2655
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2656 prt_file_error = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2657
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2658 return OK;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2659 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2660
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2661 static int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2662 prt_add_resource(struct prt_ps_resource_S *resource)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2663 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2664 FILE* fd_resource;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2665 char_u resource_buffer[512];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2666 size_t bytes_read;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2667
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2668 fd_resource = mch_fopen((char *)resource->filename, READBIN);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2669 if (fd_resource == NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2670 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2671 semsg(_(e_cant_open_file_str_2), resource->filename);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2672 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2673 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2674 prt_dsc_resources("BeginResource", prt_resource_types[resource->type],
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2675 (char *)resource->title);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2676
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2677 prt_dsc_textline("BeginDocument", (char *)resource->filename);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2678
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2679 for (;;)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2680 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2681 bytes_read = fread((char *)resource_buffer, sizeof(char_u),
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2682 sizeof(resource_buffer), fd_resource);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2683 if (ferror(fd_resource))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2684 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2685 semsg(_(e_cant_read_postscript_resource_file_str),
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2686 resource->filename);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2687 fclose(fd_resource);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2688 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2689 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2690 if (bytes_read == 0)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2691 break;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
2692 prt_write_file_raw_len(resource_buffer, (int)bytes_read);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2693 if (prt_file_error)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2694 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2695 fclose(fd_resource);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2696 return FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2697 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2698 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2699 fclose(fd_resource);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2700
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2701 prt_dsc_noarg("EndDocument");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2702
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2703 prt_dsc_noarg("EndResource");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2704
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2705 return TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2706 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2707
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2708 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
2709 mch_print_begin(prt_settings_T *psettings)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2710 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2711 int bbox[4];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2712 double left;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2713 double right;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2714 double top;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2715 double bottom;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2716 struct prt_ps_resource_S *res_prolog;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2717 struct prt_ps_resource_S *res_encoding;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2718 char buffer[256];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2719 char_u *p_encoding;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2720 struct prt_ps_resource_S *res_cidfont;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2721 struct prt_ps_resource_S *res_cmap;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2722 int retval = FALSE;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2723
32120
97255d909654 patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
2724 res_prolog = ALLOC_ONE(struct prt_ps_resource_S);
97255d909654 patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
2725 res_encoding = ALLOC_ONE(struct prt_ps_resource_S);
97255d909654 patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
2726 res_cidfont = ALLOC_ONE(struct prt_ps_resource_S);
97255d909654 patch 9.0.1391: "clear" macros are not always used
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
2727 res_cmap = ALLOC_ONE(struct prt_ps_resource_S);
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2728 if (res_prolog == NULL || res_encoding == NULL
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
2729 || res_cidfont == NULL || res_cmap == NULL)
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2730 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2731
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2732 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2733 * PS DSC Header comments - no PS code!
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2734 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2735 prt_dsc_start();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2736 prt_dsc_textline("Title", (char *)psettings->jobname);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2737 if (!get_user_name((char_u *)buffer, 256))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2738 STRCPY(buffer, "Unknown");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2739 prt_dsc_textline("For", buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2740 prt_dsc_textline("Creator", VIM_VERSION_LONG);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2741 // Note: to ensure Clean8bit I don't think we can use LC_TIME
16621
7ad3fc329e08 patch 8.1.1313: warnings for using localtime() and ctime()
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
2742
7ad3fc329e08 patch 8.1.1313: warnings for using localtime() and ctime()
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
2743 prt_dsc_textline("CreationDate", get_ctime(time(NULL), FALSE));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2744 prt_dsc_textline("DocumentData", "Clean8Bit");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2745 prt_dsc_textline("Orientation", "Portrait");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2746 prt_dsc_atend("Pages");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2747 prt_dsc_textline("PageOrder", "Ascend");
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2748 // The bbox does not change with orientation - it is always in the default
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2749 // user coordinate system! We have to recalculate right and bottom
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2750 // coordinates based on the font metrics for the bbox to be accurate.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2751 prt_page_margins(prt_mediasize[prt_media].width,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2752 prt_mediasize[prt_media].height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2753 &left, &right, &top, &bottom);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2754 bbox[0] = (int)left;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2755 if (prt_portrait)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2756 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2757 // In portrait printing the fixed point is the top left corner so we
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2758 // derive the bbox from that point. We have the expected cpl chars
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2759 // across the media and lpp lines down the media.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2760 bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height())
27453
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2761 * (double)prt_line_height);
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2762 bbox[2] = (int)(left + psettings->chars_per_line
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2763 * (double)prt_char_width + 0.5);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2764 bbox[3] = (int)(top + 0.5);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2765 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2766 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2767 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2768 // In landscape printing the fixed point is the bottom left corner so we
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2769 // derive the bbox from that point. We have lpp chars across the media
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2770 // and cpl lines up the media.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2771 bbox[1] = (int)bottom;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2772 bbox[2] = (int)(left + ((psettings->lines_per_page
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2773 + prt_header_height()) * prt_line_height) + 0.5);
27453
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2774 bbox[3] = (int)(bottom + psettings->chars_per_line
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2775 * (double)prt_char_width + 0.5);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2776 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2777 prt_dsc_ints("BoundingBox", 4, bbox);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2778 // The media width and height does not change with landscape printing!
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2779 prt_dsc_docmedia(prt_mediasize[prt_media].name,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2780 prt_mediasize[prt_media].width,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2781 prt_mediasize[prt_media].height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2782 (double)0, NULL, NULL);
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2783 // Define fonts needed
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2784 if (!prt_out_mbyte || prt_use_courier)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2785 prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2786 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2787 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2788 prt_dsc_font_resource((prt_use_courier ? NULL
27453
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2789 : "DocumentNeededResources"), &prt_ps_mb_font);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2790 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2791 prt_dsc_resources(NULL, "cmap", prt_cmap);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2792 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2793
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2794 // Search for external resources VIM supplies
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2795 if (!prt_find_resource("prolog", res_prolog))
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2796 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2797 semsg(_(e_cant_find_postscript_resource_file_str_ps), "prolog");
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2798 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2799 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2800 if (!prt_open_resource(res_prolog))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2801 goto theend;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2802 if (!prt_check_resource(res_prolog, PRT_PROLOG_VERSION))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2803 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2804 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2805 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2806 // Look for required version of multi-byte printing procset
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2807 if (!prt_find_resource("cidfont", res_cidfont))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2808 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2809 semsg(_(e_cant_find_postscript_resource_file_str_ps), "cidfont");
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2810 goto theend;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2811 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2812 if (!prt_open_resource(res_cidfont))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2813 goto theend;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2814 if (!prt_check_resource(res_cidfont, PRT_CID_PROLOG_VERSION))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2815 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2816 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2817
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2818 // Find an encoding to use for printing.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2819 // Check 'printencoding'. If not set or not found, then use 'encoding'. If
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2820 // that cannot be found then default to "latin1".
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2821 // Note: VIM specific encoding header is always skipped.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2822 if (!prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2823 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2824 p_encoding = enc_skip(p_penc);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2825 if (*p_encoding == NUL
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2826 || !prt_find_resource((char *)p_encoding, res_encoding))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2827 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2828 // 'printencoding' not set or not supported - find alternate
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2829 int props;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2830
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2831 p_encoding = enc_skip(p_enc);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2832 props = enc_canon_props(p_encoding);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2833 if (!(props & ENC_8BIT)
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2834 || !prt_find_resource((char *)p_encoding, res_encoding))
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2835 // 8-bit 'encoding' is not supported
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2836 {
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2837 // Use latin1 as default printing encoding
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2838 p_encoding = (char_u *)"latin1";
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2839 if (!prt_find_resource((char *)p_encoding, res_encoding))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2840 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2841 semsg(_(e_cant_find_postscript_resource_file_str_ps),
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2842 p_encoding);
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2843 goto theend;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2844 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2845 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2846 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2847 if (!prt_open_resource(res_encoding))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2848 goto theend;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2849 // For the moment there are no checks on encoding resource files to
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2850 // perform
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2851 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2852 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2853 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2854 p_encoding = enc_skip(p_penc);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2855 if (*p_encoding == NUL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2856 p_encoding = enc_skip(p_enc);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2857 if (prt_use_courier)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2858 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2859 // Include ASCII range encoding vector
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2860 if (!prt_find_resource(prt_ascii_encoding, res_encoding))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2861 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2862 semsg(_(e_cant_find_postscript_resource_file_str_ps),
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2863 prt_ascii_encoding);
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2864 goto theend;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2865 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2866 if (!prt_open_resource(res_encoding))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2867 goto theend;
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2868 // For the moment there are no checks on encoding resource files to
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2869 // perform
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2870 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2871 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2872
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2873 prt_conv.vc_type = CONV_NONE;
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
2874 if (!(enc_canon_props(p_enc) & enc_canon_props(p_encoding) & ENC_8BIT))
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
2875 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2876 // Set up encoding conversion if required
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2877 if (FAIL == convert_setup(&prt_conv, p_enc, p_encoding))
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2878 {
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26917
diff changeset
2879 semsg(_(e_unable_to_convert_to_print_encoding_str), p_encoding);
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2880 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2881 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2882 prt_do_conv = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2883 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2884 prt_do_conv = prt_conv.vc_type != CONV_NONE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2885
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2886 if (prt_out_mbyte && prt_custom_cmap)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2887 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2888 // Find user supplied CMap
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2889 if (!prt_find_resource(prt_cmap, res_cmap))
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2890 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26913
diff changeset
2891 semsg(_(e_cant_find_postscript_resource_file_str_ps), prt_cmap);
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2892 goto theend;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2893 }
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2894 if (!prt_open_resource(res_cmap))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2895 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2896 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2897
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2898 // List resources supplied
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2899 STRCPY(buffer, res_prolog->title);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2900 STRCAT(buffer, " ");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2901 STRCAT(buffer, res_prolog->version);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2902 prt_dsc_resources("DocumentSuppliedResources", "procset", buffer);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2903 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2904 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2905 STRCPY(buffer, res_cidfont->title);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2906 STRCAT(buffer, " ");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2907 STRCAT(buffer, res_cidfont->version);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2908 prt_dsc_resources(NULL, "procset", buffer);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2909
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2910 if (prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2911 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2912 STRCPY(buffer, res_cmap->title);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2913 STRCAT(buffer, " ");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2914 STRCAT(buffer, res_cmap->version);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2915 prt_dsc_resources(NULL, "cmap", buffer);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2916 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2917 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2918 if (!prt_out_mbyte || prt_use_courier)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2919 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2920 STRCPY(buffer, res_encoding->title);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2921 STRCAT(buffer, " ");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2922 STRCAT(buffer, res_encoding->version);
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2923 prt_dsc_resources(NULL, "encoding", buffer);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2924 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2925 prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2926 #ifdef FEAT_SYN_HL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2927 psettings->do_syntax
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2928 #else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2929 0
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2930 #endif
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2931 , prt_num_copies);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2932 prt_dsc_noarg("EndComments");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2933
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2934 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2935 * PS Document page defaults
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2936 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2937 prt_dsc_noarg("BeginDefaults");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2938
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2939 // List font resources most likely common to all pages
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2940 if (!prt_out_mbyte || prt_use_courier)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2941 prt_dsc_font_resource("PageResources", &prt_ps_courier_font);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2942 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2943 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2944 prt_dsc_font_resource((prt_use_courier ? NULL : "PageResources"),
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2945 &prt_ps_mb_font);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2946 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
2947 prt_dsc_resources(NULL, "cmap", prt_cmap);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2948 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2949
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2950 // Paper will be used for all pages
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2951 prt_dsc_textline("PageMedia", prt_mediasize[prt_media].name);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2952
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2953 prt_dsc_noarg("EndDefaults");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2954
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2955 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2956 * PS Document prolog inclusion - all required procsets.
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2957 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2958 prt_dsc_noarg("BeginProlog");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2959
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2960 // Add required procsets - NOTE: order is important!
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2961 if (!prt_add_resource(res_prolog))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2962 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2963 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2964 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2965 // Add CID font procset, and any user supplied CMap
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2966 if (!prt_add_resource(res_cidfont))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2967 goto theend;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2968 if (prt_custom_cmap && !prt_add_resource(res_cmap))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2969 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2970 }
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
2971
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2972 if (!prt_out_mbyte || prt_use_courier)
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2973 // There will be only one Roman font encoding to be included in the PS
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2974 // file.
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
2975 if (!prt_add_resource(res_encoding))
6404
18953e121be6 updated for version 7.4.533
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2976 goto theend;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2977
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2978 prt_dsc_noarg("EndProlog");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2979
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2980 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2981 * PS Document setup - must appear after the prolog
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2982 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2983 prt_dsc_noarg("BeginSetup");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2984
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2985 // Device setup - page size and number of uncollated copies
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2986 prt_write_int((int)prt_mediasize[prt_media].width);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2987 prt_write_int((int)prt_mediasize[prt_media].height);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2988 prt_write_int(0);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2989 prt_write_string("sps\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2990 prt_write_int(prt_num_copies);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2991 prt_write_string("nc\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2992 prt_write_boolean(prt_duplex);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2993 prt_write_boolean(prt_tumble);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2994 prt_write_string("dt\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2995 prt_write_boolean(prt_collate);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2996 prt_write_string("c\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2997
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2998 // Font resource inclusion and definition
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
2999 if (!prt_out_mbyte || prt_use_courier)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3000 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3001 // When using Courier for ASCII range when printing multi-byte, need to
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3002 // pick up ASCII encoding to use with it.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3003 if (prt_use_courier)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3004 p_encoding = (char_u *)prt_ascii_encoding;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3005 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3006 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3007 prt_def_font("F0", (char *)p_encoding, (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3008 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3009 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3010 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3011 prt_def_font("F1", (char *)p_encoding, (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3012 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3013 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3014 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3015 prt_def_font("F2", (char *)p_encoding, (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3016 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3017 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3018 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3019 prt_def_font("F3", (char *)p_encoding, (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3020 prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3021 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3022 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3023 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3024 // Define the CID fonts to be used in the job. Typically CJKV fonts do
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3025 // not have an italic form being a western style, so where no font is
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3026 // defined for these faces VIM falls back to an existing face.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3027 // Note: if using Courier for the ASCII range then the printout will
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3028 // have bold/italic/bolditalic regardless of the setting of printmbfont.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3029 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3030 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3031 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3032 prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3033 prt_def_cidfont("CF0", (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3034 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3035
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3036 if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD] != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3037 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3038 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3039 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3040 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3041 prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3042 prt_def_cidfont("CF1", (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3043 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3044 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3045 else
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3046 // Use ROMAN for BOLD
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3047 prt_dup_cidfont("CF0", "CF1");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3048
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3049 if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE] != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3050 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3051 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3052 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3053 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3054 prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3055 prt_def_cidfont("CF2", (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3056 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3057 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3058 else
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3059 // Use ROMAN for OBLIQUE
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3060 prt_dup_cidfont("CF0", "CF2");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3061
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3062 if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE] != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3063 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3064 prt_dsc_resources("IncludeResource", "font",
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3065 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3066 if (!prt_custom_cmap)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3067 prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3068 prt_def_cidfont("CF3", (int)prt_line_height,
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3069 prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3070 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3071 else
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3072 // Use BOLD for BOLDOBLIQUE
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3073 prt_dup_cidfont("CF1", "CF3");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3074 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3075
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3076 // Misc constant vars used for underlining and background rects
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3077 prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3078 prt_ps_font->uline_offset), 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3079 prt_def_var("UW", PRT_PS_FONT_TO_USER(prt_line_height,
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3080 prt_ps_font->uline_width), 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3081 prt_def_var("BO", prt_bgcol_offset, 2);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3082
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3083 prt_dsc_noarg("EndSetup");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3084
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3085 // Fail if any problems writing out to the PS file
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3086 retval = !prt_file_error;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3087
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3088 theend:
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3089 vim_free(res_prolog);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3090 vim_free(res_encoding);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3091 vim_free(res_cidfont);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3092 vim_free(res_cmap);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3093
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
3094 return retval;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3095 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3096
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3097 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3098 mch_print_end(prt_settings_T *psettings)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3099 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3100 prt_dsc_noarg("Trailer");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3101
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3102 /*
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3103 * Output any info we don't know in toto until we finish
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3104 */
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3105 prt_dsc_ints("Pages", 1, &prt_page_num);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3106
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3107 prt_dsc_noarg("EOF");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3108
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3109 // Write CTRL-D to close serial communication link if used.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3110 // NOTHING MUST BE WRITTEN AFTER THIS!
27490
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3111 prt_write_file((char_u *)"\004");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3112
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3113 if (!prt_file_error && psettings->outfile == NULL
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3114 && !got_int && !psettings->user_abort)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3115 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3116 // Close the file first.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3117 if (prt_ps_fd != NULL)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3118 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3119 fclose(prt_ps_fd);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3120 prt_ps_fd = NULL;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3121 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3122 prt_message((char_u *)_("Sending to printer..."));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3123
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3124 // Not printing to a file: use 'printexpr' to print the file.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3125 if (eval_printexpr(prt_ps_file_name, psettings->arguments) == FAIL)
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
3126 emsg(_(e_failed_to_print_postscript_file));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3127 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3128 prt_message((char_u *)_("Print job sent."));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3129 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3130
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3131 mch_print_cleanup();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3132 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3133
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3134 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3135 mch_print_end_page(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3136 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3137 prt_flush_buffer();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3138
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3139 prt_write_string("re sp\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3140
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3141 prt_dsc_noarg("PageTrailer");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3142
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3143 return !prt_file_error;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3144 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3145
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3146 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3147 mch_print_begin_page(char_u *str UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3148 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3149 int page_num[2];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3150
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3151 prt_page_num++;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3152
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3153 page_num[0] = page_num[1] = prt_page_num;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3154 prt_dsc_ints("Page", 2, page_num);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3155
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3156 prt_dsc_noarg("BeginPageSetup");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3157
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3158 prt_write_string("sv\n0 g\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3159 prt_in_ascii = !prt_out_mbyte;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3160 if (prt_out_mbyte)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3161 prt_write_string("CF0 sf\n");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3162 else
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3163 prt_write_string("F0 sf\n");
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3164 prt_fgcol = PRCOLOR_BLACK;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3165 prt_bgcol = PRCOLOR_WHITE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3166 prt_font = PRT_PS_FONT_ROMAN;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3167
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3168 // Set up page transformation for landscape printing.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3169 if (!prt_portrait)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3170 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3171 prt_write_int(-((int)prt_mediasize[prt_media].width));
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3172 prt_write_string("sl\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3173 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3174
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3175 prt_dsc_noarg("EndPageSetup");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3176
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3177 // We have reset the font attributes, force setting them again.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3178 curr_bg = (long_u)0xffffffff;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3179 curr_fg = (long_u)0xffffffff;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3180 curr_bold = MAYBE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3181
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3182 return !prt_file_error;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3183 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3184
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3185 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3186 mch_print_blank_page(void)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3187 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3188 return (mch_print_begin_page(NULL) ? (mch_print_end_page()) : FALSE);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3189 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3190
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3191 static float prt_pos_x = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3192 static float prt_pos_y = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3193
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3194 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3195 mch_print_start_line(int margin, int page_line)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3196 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3197 prt_pos_x = prt_left_margin;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3198 if (margin)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3199 prt_pos_x -= prt_number_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3200
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3201 prt_pos_y = prt_top_margin - prt_first_line_height -
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3202 page_line * prt_line_height;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3203
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3204 prt_attribute_change = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3205 prt_need_moveto = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3206 prt_half_width = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3207 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3208
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3209 int
14077
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3210 mch_print_text_out(char_u *textp, int len UNUSED)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3211 {
14077
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3212 char_u *p = textp;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3213 int need_break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3214 char_u ch;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3215 char_u ch_buff[8];
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3216 float char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3217 float next_pos;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3218 int in_ascii;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3219 int half_width;
13258
6acb9148d83e patch 8.0.1503: access memory beyond end of string
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3220 char_u *tofree = NULL;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3221
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3222 char_width = prt_char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3223
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3224 // Ideally VIM would create a rearranged CID font to combine a Roman and
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3225 // CJKV font to do what VIM is doing here - use a Roman font for characters
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3226 // in the ASCII range, and the original CID font for everything else.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3227 // The problem is that GhostScript still (as of 8.13) does not support
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3228 // rearranged fonts even though they have been documented by Adobe for 7
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3229 // years! If they ever do, a lot of this code will disappear.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3230 if (prt_use_courier)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3231 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3232 in_ascii = (len == 1 && *p < 0x80);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3233 if (prt_in_ascii)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3234 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3235 if (!in_ascii)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3236 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3237 // No longer in ASCII range - need to switch font
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3238 prt_in_ascii = FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3239 prt_need_font = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3240 prt_attribute_change = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3241 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3242 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3243 else if (in_ascii)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3244 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3245 // Now in ASCII range - need to switch font
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3246 prt_in_ascii = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3247 prt_need_font = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3248 prt_attribute_change = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3249 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3250 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3251 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3252 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3253 half_width = ((*mb_ptr2cells)(p) == 1);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3254 if (half_width)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3255 char_width /= 2;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3256 if (prt_half_width)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3257 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3258 if (!half_width)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3259 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3260 prt_half_width = FALSE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3261 prt_pos_x += prt_char_width/4;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3262 prt_need_moveto = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3263 prt_attribute_change = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3264 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3265 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3266 else if (half_width)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3267 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3268 prt_half_width = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3269 prt_pos_x += prt_char_width/4;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3270 prt_need_moveto = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3271 prt_attribute_change = TRUE;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3272 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3273 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3274
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3275 // Output any required changes to the graphics state, after flushing any
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3276 // text buffered so far.
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3277 if (prt_attribute_change)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3278 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3279 prt_flush_buffer();
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3280 // Reset count of number of chars that will be printed
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3281 prt_text_run = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3282
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3283 if (prt_need_moveto)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3284 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3285 prt_pos_x_moveto = prt_pos_x;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3286 prt_pos_y_moveto = prt_pos_y;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3287 prt_do_moveto = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3288
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3289 prt_need_moveto = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3290 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3291 if (prt_need_font)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3292 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3293 if (!prt_in_ascii)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3294 prt_write_string("CF");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3295 else
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3296 prt_write_string("F");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3297 prt_write_int(prt_font);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3298 prt_write_string("sf\n");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3299 prt_need_font = FALSE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3300 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3301 if (prt_need_fgcol)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3302 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3303 int r, g, b;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3304 r = ((unsigned)prt_fgcol & 0xff0000) >> 16;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3305 g = ((unsigned)prt_fgcol & 0xff00) >> 8;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3306 b = prt_fgcol & 0xff;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3307
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3308 prt_write_real(r / 255.0, 3);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3309 if (r == g && g == b)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3310 prt_write_string("g\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3311 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3312 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3313 prt_write_real(g / 255.0, 3);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3314 prt_write_real(b / 255.0, 3);
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3315 prt_write_string("r\n");
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3316 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3317 prt_need_fgcol = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3318 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3319
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3320 if (prt_bgcol != PRCOLOR_WHITE)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3321 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3322 prt_new_bgcol = prt_bgcol;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3323 if (prt_need_bgcol)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3324 prt_do_bgcol = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3325 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3326 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3327 prt_do_bgcol = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3328 prt_need_bgcol = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3329
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3330 if (prt_need_underline)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3331 prt_do_underline = prt_underline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3332 prt_need_underline = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3333
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3334 prt_attribute_change = FALSE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3335 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3336
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3337 if (prt_do_conv)
14077
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3338 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3339 // Convert from multi-byte to 8-bit encoding
13258
6acb9148d83e patch 8.0.1503: access memory beyond end of string
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3340 tofree = p = string_convert(&prt_conv, p, &len);
14077
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3341 if (p == NULL)
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3342 {
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3343 p = (char_u *)"";
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3344 len = 0;
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3345 }
873542706b0b patch 8.1.0056: crash when using :hardcopy with illegal byte
Christian Brabandt <cb@256bit.org>
parents: 13258
diff changeset
3346 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3347
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3348 if (prt_out_mbyte)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3349 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3350 // Multi-byte character strings are represented more efficiently as hex
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3351 // strings when outputting clean 8 bit PS.
13258
6acb9148d83e patch 8.0.1503: access memory beyond end of string
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3352 while (len-- > 0)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3353 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3354 ch = prt_hexchar[(unsigned)(*p) >> 4];
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3355 ga_append(&prt_ps_buffer, ch);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3356 ch = prt_hexchar[(*p) & 0xf];
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3357 ga_append(&prt_ps_buffer, ch);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3358 p++;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3359 }
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3360 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3361 else
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3362 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3363 // Add next character to buffer of characters to output.
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3364 // Note: One printed character may require several PS characters to
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3365 // represent it, but we only count them as one printed character.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3366 ch = *p;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3367 if (ch < 32 || ch == '(' || ch == ')' || ch == '\\')
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3368 {
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3369 // Convert non-printing characters to either their escape or octal
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3370 // sequence, ensures PS sent over a serial line does not interfere
27490
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3371 // with the comms protocol.
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3372 ga_append(&prt_ps_buffer, '\\');
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3373 switch (ch)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3374 {
27490
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3375 case BS: ga_append(&prt_ps_buffer, 'b'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3376 case TAB: ga_append(&prt_ps_buffer, 't'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3377 case NL: ga_append(&prt_ps_buffer, 'n'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3378 case FF: ga_append(&prt_ps_buffer, 'f'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3379 case CAR: ga_append(&prt_ps_buffer, 'r'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3380 case '(': ga_append(&prt_ps_buffer, '('); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3381 case ')': ga_append(&prt_ps_buffer, ')'); break;
fb4c30606b4a patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
3382 case '\\': ga_append(&prt_ps_buffer, '\\'); break;
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3383
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3384 default:
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3385 sprintf((char *)ch_buff, "%03o", (unsigned int)ch);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3386 ga_append(&prt_ps_buffer, ch_buff[0]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3387 ga_append(&prt_ps_buffer, ch_buff[1]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3388 ga_append(&prt_ps_buffer, ch_buff[2]);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3389 break;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3390 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3391 }
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3392 else
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3393 ga_append(&prt_ps_buffer, ch);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3394 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3395
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3396 // Need to free any translated characters
13258
6acb9148d83e patch 8.0.1503: access memory beyond end of string
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3397 vim_free(tofree);
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3398
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3399 prt_text_run += char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3400 prt_pos_x += char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3401
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3402 // The downside of fp - use relative error on right margin check
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3403 next_pos = prt_pos_x + prt_char_width;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3404 need_break = (next_pos > prt_right_margin) &&
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
3405 ((next_pos - prt_right_margin) > (prt_right_margin*1e-5));
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3406
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3407 if (need_break)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3408 prt_flush_buffer();
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3409
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3410 return need_break;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3411 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3412
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3413 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3414 mch_print_set_font(int iBold, int iItalic, int iUnderline)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3415 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3416 int font = 0;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3417
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3418 if (iBold)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3419 font |= 0x01;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3420 if (iItalic)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3421 font |= 0x02;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3422
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3423 if (font != prt_font)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3424 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3425 prt_font = font;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3426 prt_attribute_change = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3427 prt_need_font = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3428 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3429 if (prt_underline != iUnderline)
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3430 {
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3431 prt_underline = iUnderline;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3432 prt_attribute_change = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3433 prt_need_underline = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3434 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3435 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3436
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3437 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3438 mch_print_set_bg(long_u bgcol)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3439 {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 823
diff changeset
3440 prt_bgcol = (int)bgcol;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3441 prt_attribute_change = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3442 prt_need_bgcol = TRUE;
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3443 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3444
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3445 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7803
diff changeset
3446 mch_print_set_fg(long_u fgcol)
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3447 {
31667
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3448 if (fgcol == (long_u)prt_fgcol)
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3449 return;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3450
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3451 prt_fgcol = (int)fgcol;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3452 prt_attribute_change = TRUE;
b89cfd86e18e patch 9.0.1166: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31018
diff changeset
3453 prt_need_fgcol = TRUE;
442
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3454 }
c36697964844 updated for version 7.0115
vimboss
parents:
diff changeset
3455
18798
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3456 # endif //FEAT_POSTSCRIPT
f0f9692d4487 patch 8.1.2387: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3457 #endif //FEAT_PRINTER