annotate src/hardcopy.c @ 11764:b82dad3fa176 v8.0.0764

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