• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisioneb531146be0ec6cce1187568cc841718df44a296 (tree)
Zeit2005-07-24 07:25:46
Autorvimboss
Commitervimboss

Log Message

updated for version 7.0114

Ändern Zusammenfassung

Diff

diff -r 8d2b705a5a51 -r eb531146be0e runtime/doc/todo.txt
--- a/runtime/doc/todo.txt Fri Jul 22 21:54:43 2005 +0000
+++ b/runtime/doc/todo.txt Sat Jul 23 22:25:46 2005 +0000
@@ -1,4 +1,4 @@
1-*todo.txt* For Vim version 7.0aa. Last change: 2005 Jul 22
1+*todo.txt* For Vim version 7.0aa. Last change: 2005 Jul 23
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -30,20 +30,12 @@
3030 *known-bugs*
3131 -------------------- Known bugs and current work -----------------------
3232
33-Make a script to check message translations not to change the % items in
34-strings.
35-
36-Fixed Netrw plugin problems:
37-- when 'autochdir' is set the current dir is wrong (Salman Halim)
38-- "cd -" doesn't work. (Suresh Govindachar)
39-Send to Charles Campbell
40-
4133 Mac unicode patch (Da Woon Jung):
4234 - selecting proportional font breaks display
4335 - UTF-8 text causes display problems. Font replacement causes this.
4436
45-Include new PHP indent script from John Wellesz?
46- http://www.vim.org/scripts/download_script.php?src_id=4330
37+Win32: Use the free downloadable compiler 7.1. Figure out how to do debugging
38+(with Agide?) and describe it. (George Reilly)
4739
4840 autoload:
4941 - Add a Vim script in $VIMRUNTIME/tools that takes a file with a list of
@@ -56,29 +48,24 @@
5648 helpfile doc/myscript.txt
5749 For the "helpfile" item ":helptags" is run.
5850
59-Patch to alternate fold highlighting. (Anthony Iano-Fletcher, 2005 May 12)
60-More levels?
61-
6251 Awaiting response:
6352 - Win32: tearoff menu window should have a scrollbar when it's taller than
6453 the screen.
65-
66-mblen(NULL, 0) also in Vim 6.3?
54+- mblen(NULL, 0) also in Vim 6.3?
6755
6856 Win32: Crash when pasting Simplified Chinese in utf-8. (rainux, 2005 June 20)
6957
7058
7159 PLANNED FOR VERSION 7.0:
7260
73-- Support using "**" in filename for ":next", ":vimgrep", etc., so that a
74- directory tree can be searched.
7561 - REFACTORING: The main() function is very long. Move parts to separate
7662 functions, especially loops. Ideas from Walter Briscoe (2003 Apr 3, 2004
7763 Feb 9).
78- Move the printing stuff to hardcopy.c.
79-- Improve the interface between the generic GUI code and the system-specific
64+ Improve the interface between the generic GUI code and the system-specific
8065 code. Generic code handles text window with scrollbars, system-specific
8166 code menu, toolbar, etc.
67+- Support using "**" in filename for ":next", ":vimgrep", etc., so that a
68+ directory tree can be searched.
8269 - Store messages to allow SCROLLING BACK for all commands. And other "less"
8370 like commands.
8471 - "INTELLISENSE". First cleanup the Insert-mode completion.
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_bc3.mak
--- a/src/Make_bc3.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_bc3.mak Sat Jul 23 22:25:46 2005 +0000
@@ -65,6 +65,7 @@
6565 fileio.obj \
6666 fold.obj \
6767 getchar.obj \
68+ hardcopy.obj \
6869 hashtable.obj \
6970 main.obj \
7071 mark.obj \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_bc5.mak
--- a/src/Make_bc5.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_bc5.mak Sat Jul 23 22:25:46 2005 +0000
@@ -546,6 +546,7 @@
546546 $(OBJDIR)\fileio.obj \
547547 $(OBJDIR)\fold.obj \
548548 $(OBJDIR)\getchar.obj \
549+ $(OBJDIR)\hardcopy.obj \
549550 $(OBJDIR)\hashtable.obj \
550551 $(OBJDIR)\main.obj \
551552 $(OBJDIR)\mark.obj \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_cyg.mak
--- a/src/Make_cyg.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_cyg.mak Sat Jul 23 22:25:46 2005 +0000
@@ -1,6 +1,6 @@
11 #
22 # Makefile for VIM on Win32, using Cygnus gcc
3-# Last updated by Dan Sharp. Last Change: 2005 Mar 21
3+# Last updated by Dan Sharp. Last Change: 2005 Jul 23
44 #
55 # Also read INSTALLpc.txt!
66 #
@@ -403,6 +403,7 @@
403403 $(OUTDIR)/fileio.o \
404404 $(OUTDIR)/fold.o \
405405 $(OUTDIR)/getchar.o \
406+ $(OUTDIR)/hardcopy.o \
406407 $(OUTDIR)/hashtable.o \
407408 $(OUTDIR)/main.o \
408409 $(OUTDIR)/mark.o \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_dice.mak
--- a/src/Make_dice.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_dice.mak Sat Jul 23 22:25:46 2005 +0000
@@ -40,6 +40,7 @@
4040 fileio.c \
4141 fold.c \
4242 getchar.c \
43+ hardcopy.c \
4344 hashtable.c \
4445 main.c \
4546 mark.c \
@@ -82,6 +83,7 @@
8283 o/fileio.o \
8384 o/fold.o \
8485 o/getchar.o \
86+ o/hardcopy.o \
8587 o/hashtable.o \
8688 o/main.o \
8789 o/mark.o \
@@ -157,6 +159,8 @@
157159
158160 o/getchar.o: getchar.c $(SYMS)
159161
162+o/hardcopy.o: hardcopy.c $(SYMS)
163+
160164 o/hashtable.o: hashtable.c $(SYMS)
161165
162166 o/main.o: main.c $(SYMS)
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_djg.mak
--- a/src/Make_djg.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_djg.mak Sat Jul 23 22:25:46 2005 +0000
@@ -33,6 +33,7 @@
3333 obj/fileio.o \
3434 obj/fold.o \
3535 obj/getchar.o \
36+ obj/hardcopy.o \
3637 obj/hashtable.o \
3738 obj/main.o \
3839 obj/mark.o \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_ivc.mak
--- a/src/Make_ivc.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_ivc.mak Sat Jul 23 22:25:46 2005 +0000
@@ -224,6 +224,7 @@
224224 "$(INTDIR)/fileio.obj" \
225225 "$(INTDIR)/fold.obj" \
226226 "$(INTDIR)/getchar.obj" \
227+ "$(INTDIR)/hardcopy.obj" \
227228 "$(INTDIR)/hashtable.obj" \
228229 "$(INTDIR)/main.obj" \
229230 "$(INTDIR)/mark.obj" \
@@ -378,6 +379,10 @@
378379 # End Source File
379380 # Begin Source File
380381
382+SOURCE=.\hardcopy.c
383+# End Source File
384+# Begin Source File
385+
381386 SOURCE=.\hashtable.c
382387 # End Source File
383388 # Begin Source File
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_manx.mak
--- a/src/Make_manx.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_manx.mak Sat Jul 23 22:25:46 2005 +0000
@@ -48,6 +48,7 @@
4848 fileio.c \
4949 fold.c \
5050 getchar.c \
51+ hardcopy.c \
5152 hashtable.c \
5253 main.c \
5354 mark.c \
@@ -92,6 +93,7 @@
9293 obj/fileio.o \
9394 obj/fold.o \
9495 obj/getchar.o \
96+ obj/hardcopy.o \
9597 obj/hashtable.o \
9698 obj/main.o \
9799 obj/mark.o \
@@ -134,6 +136,7 @@
134136 proto/fileio.pro \
135137 proto/fold.pro \
136138 proto/getchar.pro \
139+ proto/hardcopy.pro \
137140 proto/hashtable.pro \
138141 proto/main.pro \
139142 proto/mark.pro \
@@ -249,6 +252,9 @@
249252 obj/getchar.o: getchar.c
250253 $(CCSYM) $@ getchar.c
251254
255+obj/hardcopy.o: hardcopy.c
256+ $(CCSYM) $@ hardcopy.c
257+
252258 obj/hashtable.o: hashtable.c
253259 $(CCSYM) $@ hashtable.c
254260
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_ming.mak
--- a/src/Make_ming.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_ming.mak Sat Jul 23 22:25:46 2005 +0000
@@ -371,6 +371,7 @@
371371 $(OUTDIR)/fileio.o \
372372 $(OUTDIR)/fold.o \
373373 $(OUTDIR)/getchar.o \
374+ $(OUTDIR)/hardcopy.o \
374375 $(OUTDIR)/hashtable.o \
375376 $(OUTDIR)/main.o \
376377 $(OUTDIR)/mark.o \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_morph.mak
--- a/src/Make_morph.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_morph.mak Sat Jul 23 22:25:46 2005 +0000
@@ -38,6 +38,7 @@
3838 fileio.c \
3939 fold.c \
4040 getchar.c \
41+ hardcopy.c \
4142 hashtable.c \
4243 main.c \
4344 mark.c \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_mpw.mak
--- a/src/Make_mpw.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_mpw.mak Sat Jul 23 22:25:46 2005 +0000
@@ -32,6 +32,7 @@
3232 :src:fileio.c ¶
3333 :src:fold.c ¶
3434 :src:getchar.c ¶
35+ :src:hardcopy.c ¶
3536 :src:hashtable.c ¶
3637 :src:gui.c ¶
3738 :src:gui_mac.c ¶
@@ -84,6 +85,7 @@
8485 "{ObjDir}fileio.c.x" ¶
8586 "{ObjDir}fold.c.x" ¶
8687 "{ObjDir}getchar.c.x" ¶
88+ "{ObjDir}hardcopy.c.x" ¶
8789 "{ObjDir}hashtable.c.x" ¶
8890 "{ObjDir}gui.c.x" ¶
8991 "{ObjDir}gui_mac.c.x" ¶
@@ -167,6 +169,7 @@
167169 "{ObjDir}fileio.c.x" Ä :src:fileio.c
168170 "{ObjDir}fold.c.x" Ä :src:fold.c
169171 "{ObjDir}getchar.c.x" Ä :src:getchar.c
172+"{ObjDir}hardcopy.c.x" Ä :src:hardcopy.c
170173 "{ObjDir}hashtable.c.x" Ä :src:hashtable.c
171174 "{ObjDir}gui.c.x" Ä :src:gui.c
172175 "{ObjDir}gui_mac.c.x" Ä :src:gui_mac.c
@@ -257,6 +260,7 @@
257260 :src:proto:fileio.pro ¶
258261 :src:proto:fold.pro ¶
259262 :src:proto:getchar.pro ¶
263+ :src:proto:hardcopy.pro ¶
260264 :src:proto:hashtable.pro ¶
261265 :src:proto:hangulin.pro ¶
262266 :src:proto:main.pro ¶
@@ -339,6 +343,7 @@
339343 :src:proto:fileio.pro ¶
340344 :src:proto:fold.pro ¶
341345 :src:proto:getchar.pro ¶
346+ :src:proto:hardcopy.pro ¶
342347 :src:proto:hashtable.pro ¶
343348 :src:proto:hangulin.pro ¶
344349 :src:proto:main.pro ¶
@@ -421,6 +426,7 @@
421426 :src:proto:fileio.pro ¶
422427 :src:proto:fold.pro ¶
423428 :src:proto:getchar.pro ¶
429+ :src:proto:hardcopy.pro ¶
424430 :src:proto:hashtable.pro ¶
425431 :src:proto:hangulin.pro ¶
426432 :src:proto:main.pro ¶
@@ -503,6 +509,7 @@
503509 :src:proto:fileio.pro ¶
504510 :src:proto:fold.pro ¶
505511 :src:proto:getchar.pro ¶
512+ :src:proto:hardcopy.pro ¶
506513 :src:proto:hashtable.pro ¶
507514 :src:proto:hangulin.pro ¶
508515 :src:proto:main.pro ¶
@@ -585,6 +592,7 @@
585592 :src:proto:fileio.pro ¶
586593 :src:proto:fold.pro ¶
587594 :src:proto:getchar.pro ¶
595+ :src:proto:hardcopy.pro ¶
588596 :src:proto:hashtable.pro ¶
589597 :src:proto:hangulin.pro ¶
590598 :src:proto:main.pro ¶
@@ -668,6 +676,7 @@
668676 :src:proto:fileio.pro ¶
669677 :src:proto:fold.pro ¶
670678 :src:proto:getchar.pro ¶
679+ :src:proto:hardcopy.pro ¶
671680 :src:proto:hashtable.pro ¶
672681 :src:proto:hangulin.pro ¶
673682 :src:proto:main.pro ¶
@@ -750,6 +759,7 @@
750759 :src:proto:fileio.pro ¶
751760 :src:proto:fold.pro ¶
752761 :src:proto:getchar.pro ¶
762+ :src:proto:hardcopy.pro ¶
753763 :src:proto:hashtable.pro ¶
754764 :src:proto:hangulin.pro ¶
755765 :src:proto:main.pro ¶
@@ -832,6 +842,7 @@
832842 :src:proto:fileio.pro ¶
833843 :src:proto:fold.pro ¶
834844 :src:proto:getchar.pro ¶
845+ :src:proto:hardcopy.pro ¶
835846 :src:proto:hashtable.pro ¶
836847 :src:proto:hangulin.pro ¶
837848 :src:proto:main.pro ¶
@@ -914,6 +925,7 @@
914925 :src:proto:fileio.pro ¶
915926 :src:proto:fold.pro ¶
916927 :src:proto:getchar.pro ¶
928+ :src:proto:hardcopy.pro ¶
917929 :src:proto:hashtable.pro ¶
918930 :src:proto:hangulin.pro ¶
919931 :src:proto:main.pro ¶
@@ -996,6 +1008,7 @@
9961008 :src:proto:fileio.pro ¶
9971009 :src:proto:fold.pro ¶
9981010 :src:proto:getchar.pro ¶
1011+ :src:proto:hardcopy.pro ¶
9991012 :src:proto:hashtable.pro ¶
10001013 :src:proto:hangulin.pro ¶
10011014 :src:proto:main.pro ¶
@@ -1078,6 +1091,7 @@
10781091 :src:proto:fileio.pro ¶
10791092 :src:proto:fold.pro ¶
10801093 :src:proto:getchar.pro ¶
1094+ :src:proto:hardcopy.pro ¶
10811095 :src:proto:hashtable.pro ¶
10821096 :src:proto:hangulin.pro ¶
10831097 :src:proto:main.pro ¶
@@ -1160,6 +1174,7 @@
11601174 :src:proto:fileio.pro ¶
11611175 :src:proto:fold.pro ¶
11621176 :src:proto:getchar.pro ¶
1177+ :src:proto:hardcopy.pro ¶
11631178 :src:proto:hashtable.pro ¶
11641179 :src:proto:hangulin.pro ¶
11651180 :src:proto:main.pro ¶
@@ -1242,6 +1257,7 @@
12421257 :src:proto:fileio.pro ¶
12431258 :src:proto:fold.pro ¶
12441259 :src:proto:getchar.pro ¶
1260+ :src:proto:hardcopy.pro ¶
12451261 :src:proto:hashtable.pro ¶
12461262 :src:proto:hangulin.pro ¶
12471263 :src:proto:main.pro ¶
@@ -1366,6 +1382,89 @@
13661382 :src:proto:if_perl.pro ¶
13671383 :src:proto:if_perlsfio.pro
13681384
1385+:obj:hardcopy.c.x Ä ¶
1386+ :src:hardcopy.c ¶
1387+ :src:vim.h ¶
1388+ :src:auto:config.h ¶
1389+ :src:feature.h ¶
1390+ :src:os_unix.h ¶
1391+ :src:os_mac.h ¶
1392+ :src:workshop.h ¶
1393+ :src:ascii.h ¶
1394+ :src:keymap.h ¶
1395+ :src:term.h ¶
1396+ :src:macros.h ¶
1397+ :src:structs.h ¶
1398+ :src:globals.h ¶
1399+ :src:option.h ¶
1400+ :src:ex_cmds.h ¶
1401+ :src:proto.h ¶
1402+ :src:integration.h ¶
1403+ :src:wsdebug.h ¶
1404+ :src:regexp.h ¶
1405+ :src:gui.h ¶
1406+ :src:farsi.h ¶
1407+ :src:proto:os_unix.pro ¶
1408+ :src:proto:os_mac.pro ¶
1409+ :src:proto:buffer.pro ¶
1410+ :src:proto:charset.pro ¶
1411+ :src:proto:if_cscope.pro ¶
1412+ :src:proto:diff.pro ¶
1413+ :src:proto:digraph.pro ¶
1414+ :src:proto:edit.pro ¶
1415+ :src:proto:eval.pro ¶
1416+ :src:proto:ex_cmds.pro ¶
1417+ :src:proto:ex_cmds2.pro ¶
1418+ :src:proto:ex_docmd.pro ¶
1419+ :src:proto:ex_eval.pro ¶
1420+ :src:proto:ex_getln.pro ¶
1421+ :src:proto:fileio.pro ¶
1422+ :src:proto:fold.pro ¶
1423+ :src:proto:getchar.pro ¶
1424+ :src:proto:hardcopy.pro ¶
1425+ :src:proto:hashtable.pro ¶
1426+ :src:proto:hangulin.pro ¶
1427+ :src:proto:main.pro ¶
1428+ :src:proto:mark.pro ¶
1429+ :src:proto:memfile.pro ¶
1430+ :src:proto:memline.pro ¶
1431+ :src:proto:menu.pro ¶
1432+ :src:proto:message.pro ¶
1433+ :src:proto:misc1.pro ¶
1434+ :src:proto:misc2.pro ¶
1435+ :src:proto:move.pro ¶
1436+ :src:proto:multibyte.pro ¶
1437+ :src:proto:normal.pro ¶
1438+ :src:proto:ops.pro ¶
1439+ :src:proto:option.pro ¶
1440+ :src:proto:quickfix.pro ¶
1441+ :src:proto:regexp.pro ¶
1442+ :src:proto:screen.pro ¶
1443+ :src:proto:search.pro ¶
1444+ :src:proto:spell.pro ¶
1445+ :src:proto:syntax.pro ¶
1446+ :src:proto:tag.pro ¶
1447+ :src:proto:term.pro ¶
1448+ :src:proto:termlib.pro ¶
1449+ :src:proto:ui.pro ¶
1450+ :src:proto:undo.pro ¶
1451+ :src:proto:version.pro ¶
1452+ :src:proto:window.pro ¶
1453+ :src:proto:if_python.pro ¶
1454+ :src:proto:if_tcl.pro ¶
1455+ :src:proto:if_ruby.pro ¶
1456+ :src:proto:gui.pro ¶
1457+ :src:proto:pty.pro ¶
1458+ :src:proto:gui_gtk.pro ¶
1459+ :src:proto:gui_gtk_x11.pro ¶
1460+ :src:proto:gui_motif.pro ¶
1461+ :src:proto:gui_athena.pro ¶
1462+ :src:proto:gui_mac.pro ¶
1463+ :src:proto:gui_x11.pro ¶
1464+ :src:proto:workshop.pro ¶
1465+ :src:proto:if_perl.pro ¶
1466+ :src:proto:if_perlsfio.pro
1467+
13691468 :obj:hashtable.c.x Ä ¶
13701469 :src:hashtable.c ¶
13711470 :src:vim.h ¶
@@ -1405,6 +1504,7 @@
14051504 :src:proto:fileio.pro ¶
14061505 :src:proto:fold.pro ¶
14071506 :src:proto:getchar.pro ¶
1507+ :src:proto:hardcopy.pro ¶
14081508 :src:proto:hashtable.pro ¶
14091509 :src:proto:hangulin.pro ¶
14101510 :src:proto:main.pro ¶
@@ -1487,6 +1587,7 @@
14871587 :src:proto:fileio.pro ¶
14881588 :src:proto:fold.pro ¶
14891589 :src:proto:getchar.pro ¶
1590+ :src:proto:hardcopy.pro ¶
14901591 :src:proto:hashtable.pro ¶
14911592 :src:proto:hangulin.pro ¶
14921593 :src:proto:main.pro ¶
@@ -1569,6 +1670,7 @@
15691670 :src:proto:fileio.pro ¶
15701671 :src:proto:fold.pro ¶
15711672 :src:proto:getchar.pro ¶
1673+ :src:proto:hardcopy.pro ¶
15721674 :src:proto:hashtable.pro ¶
15731675 :src:proto:hangulin.pro ¶
15741676 :src:proto:main.pro ¶
@@ -1677,6 +1779,7 @@
16771779 :src:proto:fileio.pro ¶
16781780 :src:proto:fold.pro ¶
16791781 :src:proto:getchar.pro ¶
1782+ :src:proto:hardcopy.pro ¶
16801783 :src:proto:hashtable.pro ¶
16811784 :src:proto:hangulin.pro ¶
16821785 :src:proto:main.pro ¶
@@ -1760,6 +1863,7 @@
17601863 :src:proto:fileio.pro ¶
17611864 :src:proto:fold.pro ¶
17621865 :src:proto:getchar.pro ¶
1866+ :src:proto:hardcopy.pro ¶
17631867 :src:proto:hashtable.pro ¶
17641868 :src:proto:hangulin.pro ¶
17651869 :src:proto:main.pro ¶
@@ -1842,6 +1946,7 @@
18421946 :src:proto:fileio.pro ¶
18431947 :src:proto:fold.pro ¶
18441948 :src:proto:getchar.pro ¶
1949+ :src:proto:hardcopy.pro ¶
18451950 :src:proto:hashtable.pro ¶
18461951 :src:proto:hangulin.pro ¶
18471952 :src:proto:main.pro ¶
@@ -1924,6 +2029,7 @@
19242029 :src:proto:fileio.pro ¶
19252030 :src:proto:fold.pro ¶
19262031 :src:proto:getchar.pro ¶
2032+ :src:proto:hardcopy.pro ¶
19272033 :src:proto:hashtable.pro ¶
19282034 :src:proto:hangulin.pro ¶
19292035 :src:proto:main.pro ¶
@@ -2006,6 +2112,7 @@
20062112 :src:proto:fileio.pro ¶
20072113 :src:proto:fold.pro ¶
20082114 :src:proto:getchar.pro ¶
2115+ :src:proto:hardcopy.pro ¶
20092116 :src:proto:hashtable.pro ¶
20102117 :src:proto:hangulin.pro ¶
20112118 :src:proto:main.pro ¶
@@ -2088,6 +2195,7 @@
20882195 :src:proto:fileio.pro ¶
20892196 :src:proto:fold.pro ¶
20902197 :src:proto:getchar.pro ¶
2198+ :src:proto:hardcopy.pro ¶
20912199 :src:proto:hashtable.pro ¶
20922200 :src:proto:hangulin.pro ¶
20932201 :src:proto:main.pro ¶
@@ -2170,6 +2278,7 @@
21702278 :src:proto:fileio.pro ¶
21712279 :src:proto:fold.pro ¶
21722280 :src:proto:getchar.pro ¶
2281+ :src:proto:hardcopy.pro ¶
21732282 :src:proto:hashtable.pro ¶
21742283 :src:proto:hangulin.pro ¶
21752284 :src:proto:main.pro ¶
@@ -2253,6 +2362,7 @@
22532362 :src:proto:fileio.pro ¶
22542363 :src:proto:fold.pro ¶
22552364 :src:proto:getchar.pro ¶
2365+ :src:proto:hardcopy.pro ¶
22562366 :src:proto:hashtable.pro ¶
22572367 :src:proto:hangulin.pro ¶
22582368 :src:proto:main.pro ¶
@@ -2335,6 +2445,7 @@
23352445 :src:proto:fileio.pro ¶
23362446 :src:proto:fold.pro ¶
23372447 :src:proto:getchar.pro ¶
2448+ :src:proto:hardcopy.pro ¶
23382449 :src:proto:hashtable.pro ¶
23392450 :src:proto:hangulin.pro ¶
23402451 :src:proto:main.pro ¶
@@ -2417,6 +2528,7 @@
24172528 :src:proto:fileio.pro ¶
24182529 :src:proto:fold.pro ¶
24192530 :src:proto:getchar.pro ¶
2531+ :src:proto:hardcopy.pro ¶
24202532 :src:proto:hashtable.pro ¶
24212533 :src:proto:hangulin.pro ¶
24222534 :src:proto:main.pro ¶
@@ -2499,6 +2611,7 @@
24992611 :src:proto:fileio.pro ¶
25002612 :src:proto:fold.pro ¶
25012613 :src:proto:getchar.pro ¶
2614+ :src:proto:hardcopy.pro ¶
25022615 :src:proto:hashtable.pro ¶
25032616 :src:proto:hangulin.pro ¶
25042617 :src:proto:main.pro ¶
@@ -2581,6 +2694,7 @@
25812694 :src:proto:fileio.pro ¶
25822695 :src:proto:fold.pro ¶
25832696 :src:proto:getchar.pro ¶
2697+ :src:proto:hardcopy.pro ¶
25842698 :src:proto:hashtable.pro ¶
25852699 :src:proto:hangulin.pro ¶
25862700 :src:proto:main.pro ¶
@@ -2663,6 +2777,7 @@
26632777 :src:proto:fileio.pro ¶
26642778 :src:proto:fold.pro ¶
26652779 :src:proto:getchar.pro ¶
2780+ :src:proto:hardcopy.pro ¶
26662781 :src:proto:hashtable.pro ¶
26672782 :src:proto:hangulin.pro ¶
26682783 :src:proto:main.pro ¶
@@ -2745,6 +2860,7 @@
27452860 :src:proto:fileio.pro ¶
27462861 :src:proto:fold.pro ¶
27472862 :src:proto:getchar.pro ¶
2863+ :src:proto:hardcopy.pro ¶
27482864 :src:proto:hashtable.pro ¶
27492865 :src:proto:hangulin.pro ¶
27502866 :src:proto:main.pro ¶
@@ -2827,6 +2943,7 @@
28272943 :src:proto:fileio.pro ¶
28282944 :src:proto:fold.pro ¶
28292945 :src:proto:getchar.pro ¶
2946+ :src:proto:hardcopy.pro ¶
28302947 :src:proto:hashtable.pro ¶
28312948 :src:proto:hangulin.pro ¶
28322949 :src:proto:main.pro ¶
@@ -2909,6 +3026,7 @@
29093026 :src:proto:fileio.pro ¶
29103027 :src:proto:fold.pro ¶
29113028 :src:proto:getchar.pro ¶
3029+ :src:proto:hardcopy.pro ¶
29123030 :src:proto:hashtable.pro ¶
29133031 :src:proto:hangulin.pro ¶
29143032 :src:proto:main.pro ¶
@@ -2991,6 +3109,7 @@
29913109 :src:proto:fileio.pro ¶
29923110 :src:proto:fold.pro ¶
29933111 :src:proto:getchar.pro ¶
3112+ :src:proto:hardcopy.pro ¶
29943113 :src:proto:hashtable.pro ¶
29953114 :src:proto:hangulin.pro ¶
29963115 :src:proto:main.pro ¶
@@ -3073,6 +3192,7 @@
30733192 :src:proto:fileio.pro ¶
30743193 :src:proto:fold.pro ¶
30753194 :src:proto:getchar.pro ¶
3195+ :src:proto:hardcopy.pro ¶
30763196 :src:proto:hashtable.pro ¶
30773197 :src:proto:hangulin.pro ¶
30783198 :src:proto:main.pro ¶
@@ -3155,6 +3275,7 @@
31553275 :src:proto:fileio.pro ¶
31563276 :src:proto:fold.pro ¶
31573277 :src:proto:getchar.pro ¶
3278+ :src:proto:hardcopy.pro ¶
31583279 :src:proto:hashtable.pro ¶
31593280 :src:proto:hangulin.pro ¶
31603281 :src:proto:main.pro ¶
@@ -3237,6 +3358,7 @@
32373358 :src:proto:fileio.pro ¶
32383359 :src:proto:fold.pro ¶
32393360 :src:proto:getchar.pro ¶
3361+ :src:proto:hardcopy.pro ¶
32403362 :src:proto:hashtable.pro ¶
32413363 :src:proto:hangulin.pro ¶
32423364 :src:proto:main.pro ¶
@@ -3319,6 +3441,7 @@
33193441 :src:proto:fileio.pro ¶
33203442 :src:proto:fold.pro ¶
33213443 :src:proto:getchar.pro ¶
3444+ :src:proto:hardcopy.pro ¶
33223445 :src:proto:hashtable.pro ¶
33233446 :src:proto:hangulin.pro ¶
33243447 :src:proto:main.pro ¶
@@ -3401,6 +3524,7 @@
34013524 :src:proto:fileio.pro ¶
34023525 :src:proto:fold.pro ¶
34033526 :src:proto:getchar.pro ¶
3527+ :src:proto:hardcopy.pro ¶
34043528 :src:proto:hashtable.pro ¶
34053529 :src:proto:hangulin.pro ¶
34063530 :src:proto:main.pro ¶
@@ -3483,6 +3607,7 @@
34833607 :src:proto:fileio.pro ¶
34843608 :src:proto:fold.pro ¶
34853609 :src:proto:getchar.pro ¶
3610+ :src:proto:hardcopy.pro ¶
34863611 :src:proto:hashtable.pro ¶
34873612 :src:proto:hangulin.pro ¶
34883613 :src:proto:main.pro ¶
@@ -3565,6 +3690,7 @@
35653690 :src:proto:fileio.pro ¶
35663691 :src:proto:fold.pro ¶
35673692 :src:proto:getchar.pro ¶
3693+ :src:proto:hardcopy.pro ¶
35683694 :src:proto:hashtable.pro ¶
35693695 :src:proto:hangulin.pro ¶
35703696 :src:proto:main.pro ¶
@@ -3648,6 +3774,7 @@
36483774 :src:proto:fileio.pro ¶
36493775 :src:proto:fold.pro ¶
36503776 :src:proto:getchar.pro ¶
3777+ :src:proto:hardcopy.pro ¶
36513778 :src:proto:hashtable.pro ¶
36523779 :src:proto:hangulin.pro ¶
36533780 :src:proto:main.pro ¶
@@ -3729,6 +3856,7 @@
37293856 :src:proto:fileio.pro ¶
37303857 :src:proto:fold.pro ¶
37313858 :src:proto:getchar.pro ¶
3859+ :src:proto:hardcopy.pro ¶
37323860 :src:proto:hashtable.pro ¶
37333861 :src:proto:hangulin.pro ¶
37343862 :src:proto:main.pro ¶
@@ -3811,6 +3939,7 @@
38113939 :src:proto:fileio.pro ¶
38123940 :src:proto:fold.pro ¶
38133941 :src:proto:getchar.pro ¶
3942+ :src:proto:hardcopy.pro ¶
38143943 :src:proto:hashtable.pro ¶
38153944 :src:proto:hangulin.pro ¶
38163945 :src:proto:main.pro ¶
@@ -3894,6 +4023,7 @@
38944023 :src:proto:fileio.pro ¶
38954024 :src:proto:fold.pro ¶
38964025 :src:proto:getchar.pro ¶
4026+ :src:proto:hardcopy.pro ¶
38974027 :src:proto:hashtable.pro ¶
38984028 :src:proto:hangulin.pro ¶
38994029 :src:proto:main.pro ¶
@@ -3976,6 +4106,7 @@
39764106 :src:proto:fileio.pro ¶
39774107 :src:proto:fold.pro ¶
39784108 :src:proto:getchar.pro ¶
4109+ :src:proto:hardcopy.pro ¶
39794110 :src:proto:hashtable.pro ¶
39804111 :src:proto:hangulin.pro ¶
39814112 :src:proto:main.pro ¶
@@ -4058,6 +4189,7 @@
40584189 :src:proto:fileio.pro ¶
40594190 :src:proto:fold.pro ¶
40604191 :src:proto:getchar.pro ¶
4192+ :src:proto:hardcopy.pro ¶
40614193 :src:proto:hashtable.pro ¶
40624194 :src:proto:hangulin.pro ¶
40634195 :src:proto:main.pro ¶
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_mvc.mak
--- a/src/Make_mvc.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_mvc.mak Sat Jul 23 22:25:46 2005 +0000
@@ -384,6 +384,7 @@
384384 $(OUTDIR)\fileio.obj \
385385 $(OUTDIR)\fold.obj \
386386 $(OUTDIR)\getchar.obj \
387+ $(OUTDIR)\hardcopy.obj \
387388 $(OUTDIR)\hashtable.obj \
388389 $(OUTDIR)\main.obj \
389390 $(OUTDIR)\mark.obj \
@@ -817,6 +818,8 @@
817818
818819 $(OUTDIR)/getchar.obj: $(OUTDIR) getchar.c $(INCL)
819820
821+$(OUTDIR)/hardcopy.obj: $(OUTDIR) hardcopy.c $(INCL)
822+
820823 $(OUTDIR)/hashtable.obj: $(OUTDIR) hashtable.c $(INCL)
821824
822825 $(OUTDIR)/gui.obj: $(OUTDIR) gui.c $(INCL) $(GUI_INCL)
@@ -965,6 +968,7 @@
965968 proto/ex_getln.pro \
966969 proto/fileio.pro \
967970 proto/getchar.pro \
971+ proto/hardcopy.pro \
968972 proto/hashtable.pro \
969973 proto/main.pro \
970974 proto/mark.pro \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_os2.mak
--- a/src/Make_os2.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_os2.mak Sat Jul 23 22:25:46 2005 +0000
@@ -53,6 +53,7 @@
5353 fileio.o \
5454 fold.o \
5555 getchar.o \
56+ hardcopy.o \
5657 hashtable.o \
5758 main.o \
5859 mark.o \
@@ -124,6 +125,7 @@
124125 fileio.o: fileio.c $(INCL)
125126 fold.o: fold.c $(INCL)
126127 getchar.o: getchar.c $(INCL)
128+hardcopy.o: hardcopy.c $(INCL)
127129 hashtable.o: hashtable.c $(INCL)
128130 main.o: main.c $(INCL)
129131 mark.o: mark.c $(INCL)
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_ro.mak
--- a/src/Make_ro.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_ro.mak Sat Jul 23 22:25:46 2005 +0000
@@ -12,7 +12,8 @@
1212 ASMFLAGS = -throwback -objasm -gcc
1313
1414 OBJS = o.buffer o.charset o.diff o.digraph o.edit o.eval o.ex_cmds o.ex_cmds2 \
15- o.ex_docmd o.ex_eval o.ex_getln o.fileio o.fold o.getchar o.hashtable o.main o.mark o.mbyte \
15+ o.ex_docmd o.ex_eval o.ex_getln o.fileio o.fold o.getchar \
16+ o.hardcopy o.hashtable o.main o.mark o.mbyte \
1617 o.memfile o.memline o.menu o.message o.misc1 o.misc2 o.move \
1718 o.normal o.ops o.option o.quickfix o.regexp o.screen o.search \
1819 o.spell o.syntax o.tag o.term o.termlib o.ui o.undo o.version \
@@ -65,6 +66,8 @@
6566
6667 o.getchar: c.getchar
6768
69+o.hardcopy: c.hardcopy
70+
6871 o.hashtable: c.hashtable
6972
7073 o.gui: c.gui
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_sas.mak
--- a/src/Make_sas.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_sas.mak Sat Jul 23 22:25:46 2005 +0000
@@ -103,6 +103,7 @@
103103 fileio.c \
104104 fold.c \
105105 getchar.c \
106+ hardcopy.c \
106107 hashtable.c \
107108 main.c \
108109 mark.c \
@@ -146,6 +147,7 @@
146147 fileio.o \
147148 fold.o \
148149 getchar.o \
150+ hardcopy.o \
149151 hashtable.o \
150152 main.o \
151153 mark.o \
@@ -189,6 +191,7 @@
189191 proto/fileio.pro \
190192 proto/fold.pro \
191193 proto/getchar.pro \
194+ proto/hardcopy.pro \
192195 proto/hashtable.pro \
193196 proto/main.pro \
194197 proto/mark.pro \
@@ -300,6 +303,8 @@
300303 proto/fold.pro: fold.c
301304 getchar.o: getchar.c
302305 proto/getchar.pro: getchar.c
306+hardcopy.o: hardcopy.c
307+proto/hardcopy.pro: hardcopy.c
303308 hashtable.o: hashtable.c
304309 proto/hashtable.pro: hashtable.c
305310 main.o: main.c
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_vms.mms
--- a/src/Make_vms.mms Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_vms.mms Sat Jul 23 22:25:46 2005 +0000
@@ -2,7 +2,7 @@
22 # Makefile for Vim on OpenVMS
33 #
44 # Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com>
5-# Last change: 2005 Jul 12
5+# Last change: 2005 Jul 23
66 #
77 # This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
88 # with MMS and MMK
@@ -287,7 +287,7 @@
287287
288288 SRC = buffer.c charset.c diff.c digraph.c edit.c eval.c ex_cmds.c ex_cmds2.c \
289289 ex_docmd.c ex_eval.c ex_getln.c if_xcmdsrv.c fileio.c fold.c getchar.c \
290- hashtable.c, main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
290+ hardcopy.c hashtable.c main.c mark.c menu.c mbyte.c memfile.c memline.c message.c misc1.c \
291291 misc2.c move.c normal.c ops.c option.c quickfix.c regexp.c search.c \
292292 spell.c syntax.c tag.c term.c termlib.c ui.c undo.c version.c screen.c \
293293 window.c os_unix.c os_vms.c pathdef.c \
@@ -296,7 +296,7 @@
296296
297297 OBJ = buffer.obj charset.obj diff.obj digraph.obj edit.obj eval.obj \
298298 ex_cmds.obj ex_cmds2.obj ex_docmd.obj ex_eval.obj ex_getln.obj \
299- if_xcmdsrv.obj fileio.obj fold.obj getchar.obj hashtable.obj main.obj mark.obj \
299+ if_xcmdsrv.obj fileio.obj fold.obj getchar.obj hardcopy.obj hashtable.obj main.obj mark.obj \
300300 menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \
301301 move.obj mbyte.obj normal.obj ops.obj option.obj quickfix.obj \
302302 regexp.obj search.obj spell.obj syntax.obj tag.obj term.obj termlib.obj \
@@ -527,6 +527,10 @@
527527 ascii.h keymap.h term.h macros.h structs.h regexp.h \
528528 gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
529529 globals.h farsi.h arabic.h
530+hardcopy.obj : hardcopy.c vim.h [.auto]config.h feature.h os_unix.h \
531+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
532+ gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
533+ globals.h farsi.h arabic.h
530534 hashtable.obj : hashtable.c vim.h [.auto]config.h feature.h os_unix.h \
531535 ascii.h keymap.h term.h macros.h structs.h regexp.h \
532536 gui.h gui_beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
diff -r 8d2b705a5a51 -r eb531146be0e src/Make_w16.mak
--- a/src/Make_w16.mak Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Make_w16.mak Sat Jul 23 22:25:46 2005 +0000
@@ -87,6 +87,7 @@
8787 $(INTDIR)\fileio.obj\
8888 $(INTDIR)\fold.obj\
8989 $(INTDIR)\getchar.obj\
90+ $(INTDIR)\hardcopy.obj\
9091 $(INTDIR)\hashtable.obj\
9192 $(INTDIR)\gui.obj\
9293 $(INTDIR)\gui_w16.obj\
diff -r 8d2b705a5a51 -r eb531146be0e src/Makefile
--- a/src/Makefile Fri Jul 22 21:54:43 2005 +0000
+++ b/src/Makefile Sat Jul 23 22:25:46 2005 +0000
@@ -1343,6 +1343,7 @@
13431343 fileio.c \
13441344 fold.c \
13451345 getchar.c \
1346+ hardcopy.c \
13461347 hashtable.c \
13471348 if_cscope.c \
13481349 if_xcmdsrv.c \
@@ -1411,6 +1412,7 @@
14111412 objects/fileio.o \
14121413 objects/fold.o \
14131414 objects/getchar.o \
1415+ objects/hardcopy.o \
14141416 objects/hashtable.o \
14151417 $(HANGULIN_OBJ) \
14161418 objects/if_cscope.o \
@@ -1468,6 +1470,7 @@
14681470 fileio.pro \
14691471 fold.pro \
14701472 getchar.pro \
1473+ hardcopy.pro \
14711474 hashtable.pro \
14721475 hangulin.pro \
14731476 if_cscope.pro \
@@ -1599,7 +1602,9 @@
15991602 # Generate the converted .mo files separately, it's no problem if this fails.
16001603 languages:
16011604 @if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
1602- cd $(PODIR); CC="$(CC)" $(MAKE) prefix=$(DESTDIR)$(prefix); \
1605+ cd $(PODIR); \
1606+ CC="$(CC)" $(MAKE) check; \
1607+ CC="$(CC)" $(MAKE) prefix=$(DESTDIR)$(prefix); \
16031608 fi
16041609 -@if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
16051610 cd $(PODIR); CC="$(CC)" $(MAKE) prefix=$(DESTDIR)$(prefix) converted; \
@@ -2285,6 +2290,9 @@
22852290 objects/getchar.o: getchar.c
22862291 $(CCC) -o $@ getchar.c
22872292
2293+objects/hardcopy.o: hardcopy.c
2294+ $(CCC) -o $@ hardcopy.c
2295+
22882296 objects/hashtable.o: hashtable.c
22892297 $(CCC) -o $@ hashtable.c
22902298
@@ -2637,6 +2645,10 @@
26372645 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
26382646 gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
26392647 globals.h farsi.h arabic.h
2648+objects/hardcopy.o: hardcopy.c vim.h auto/config.h feature.h os_unix.h \
2649+ auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
2650+ gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
2651+ globals.h farsi.h arabic.h
26402652 objects/hashtable.o: hashtable.c vim.h auto/config.h feature.h os_unix.h \
26412653 auto/osdef.h ascii.h keymap.h term.h macros.h structs.h regexp.h \
26422654 gui.h gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
diff -r 8d2b705a5a51 -r eb531146be0e src/ex_cmds2.c
--- a/src/ex_cmds2.c Fri Jul 22 21:54:43 2005 +0000
+++ b/src/ex_cmds2.c Sat Jul 23 22:25:46 2005 +0000
@@ -3627,3528 +3627,6 @@
36273627 }
36283628 #endif
36293629
3630-#if defined(FEAT_PRINTER) || defined(PROTO)
3631-/*
3632- * Printing code (Machine-independent.)
3633- * To implement printing on a platform, the following functions must be
3634- * defined:
3635- *
3636- * int mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
3637- * Called once. Code should display printer dialogue (if appropriate) and
3638- * determine printer font and margin settings. Reset has_color if the printer
3639- * doesn't support colors at all.
3640- * Returns FAIL to abort.
3641- *
3642- * int mch_print_begin(prt_settings_T *settings)
3643- * Called to start the print job.
3644- * Return FALSE to abort.
3645- *
3646- * int mch_print_begin_page(char_u *msg)
3647- * Called at the start of each page.
3648- * "msg" indicates the progress of the print job, can be NULL.
3649- * Return FALSE to abort.
3650- *
3651- * int mch_print_end_page()
3652- * Called at the end of each page.
3653- * Return FALSE to abort.
3654- *
3655- * int mch_print_blank_page()
3656- * Called to generate a blank page for collated, duplex, multiple copy
3657- * document. Return FALSE to abort.
3658- *
3659- * void mch_print_end(prt_settings_T *psettings)
3660- * Called at normal end of print job.
3661- *
3662- * void mch_print_cleanup()
3663- * Called if print job ends normally or is abandoned. Free any memory, close
3664- * devices and handles. Also called when mch_print_begin() fails, but not
3665- * when mch_print_init() fails.
3666- *
3667- * void mch_print_set_font(int Bold, int Italic, int Underline);
3668- * Called whenever the font style changes.
3669- *
3670- * void mch_print_set_bg(long bgcol);
3671- * Called to set the background color for the following text. Parameter is an
3672- * RGB value.
3673- *
3674- * void mch_print_set_fg(long fgcol);
3675- * Called to set the foreground color for the following text. Parameter is an
3676- * RGB value.
3677- *
3678- * mch_print_start_line(int margin, int page_line)
3679- * Sets the current position at the start of line "page_line".
3680- * If margin is TRUE start in the left margin (for header and line number).
3681- *
3682- * int mch_print_text_out(char_u *p, int len);
3683- * Output one character of text p[len] at the current position.
3684- * Return TRUE if there is no room for another character in the same line.
3685- *
3686- * Note that the generic code has no idea of margins. The machine code should
3687- * simply make the page look smaller! The header and the line numbers are
3688- * printed in the margin.
3689- */
3690-
3691-#ifdef FEAT_SYN_HL
3692-static const long_u cterm_color_8[8] =
3693-{
3694- (long_u)0x000000L, (long_u)0xff0000L, (long_u)0x00ff00L, (long_u)0xffff00L,
3695- (long_u)0x0000ffL, (long_u)0xff00ffL, (long_u)0x00ffffL, (long_u)0xffffffL
3696-};
3697-
3698-static const long_u cterm_color_16[16] =
3699-{
3700- (long_u)0x000000L, (long_u)0x0000c0L, (long_u)0x008000L, (long_u)0x004080L,
3701- (long_u)0xc00000L, (long_u)0xc000c0L, (long_u)0x808000L, (long_u)0xc0c0c0L,
3702- (long_u)0x808080L, (long_u)0x6060ffL, (long_u)0x00ff00L, (long_u)0x00ffffL,
3703- (long_u)0xff8080L, (long_u)0xff40ffL, (long_u)0xffff00L, (long_u)0xffffffL
3704-};
3705-
3706-static int current_syn_id;
3707-#endif
3708-
3709-#define PRCOLOR_BLACK (long_u)0
3710-#define PRCOLOR_WHITE (long_u)0xFFFFFFL
3711-
3712-static int curr_italic;
3713-static int curr_bold;
3714-static int curr_underline;
3715-static long_u curr_bg;
3716-static long_u curr_fg;
3717-static int page_count;
3718-
3719-/*
3720- * These values determine the print position on a page.
3721- */
3722-typedef struct
3723-{
3724- int lead_spaces; /* remaining spaces for a TAB */
3725- int print_pos; /* virtual column for computing TABs */
3726- colnr_T column; /* byte column */
3727- linenr_T file_line; /* line nr in the buffer */
3728- long_u bytes_printed; /* bytes printed so far */
3729- int ff; /* seen form feed character */
3730-} prt_pos_T;
3731-
3732-#ifdef FEAT_SYN_HL
3733-static long_u darken_rgb __ARGS((long_u rgb));
3734-static long_u prt_get_term_color __ARGS((int colorindex));
3735-#endif
3736-static void prt_set_fg __ARGS((long_u fg));
3737-static void prt_set_bg __ARGS((long_u bg));
3738-static void prt_set_font __ARGS((int bold, int italic, int underline));
3739-static void prt_line_number __ARGS((prt_settings_T *psettings, int page_line, linenr_T lnum));
3740-static void prt_header __ARGS((prt_settings_T *psettings, int pagenum, linenr_T lnum));
3741-static void prt_message __ARGS((char_u *s));
3742-static colnr_T hardcopy_line __ARGS((prt_settings_T *psettings, int page_line, prt_pos_T *ppos));
3743-static void prt_get_attr __ARGS((int hl_id, prt_text_attr_T* pattr, int modec));
3744-
3745-#ifdef FEAT_SYN_HL
3746-/*
3747- * If using a dark background, the colors will probably be too bright to show
3748- * up well on white paper, so reduce their brightness.
3749- */
3750- static long_u
3751-darken_rgb(rgb)
3752- long_u rgb;
3753-{
3754- return ((rgb >> 17) << 16)
3755- + (((rgb & 0xff00) >> 9) << 8)
3756- + ((rgb & 0xff) >> 1);
3757-}
3758-
3759- static long_u
3760-prt_get_term_color(colorindex)
3761- int colorindex;
3762-{
3763- /* TODO: Should check for xterm with 88 or 256 colors. */
3764- if (t_colors > 8)
3765- return cterm_color_16[colorindex % 16];
3766- return cterm_color_8[colorindex % 8];
3767-}
3768-
3769- static void
3770-prt_get_attr(hl_id, pattr, modec)
3771- int hl_id;
3772- prt_text_attr_T *pattr;
3773- int modec;
3774-{
3775- int colorindex;
3776- long_u fg_color;
3777- long_u bg_color;
3778- char *color;
3779-
3780- pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL);
3781- pattr->italic = (highlight_has_attr(hl_id, HL_ITALIC, modec) != NULL);
3782- pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL);
3783- pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
3784-
3785-# ifdef FEAT_GUI
3786- if (gui.in_use)
3787- {
3788- bg_color = highlight_gui_color_rgb(hl_id, FALSE);
3789- if (bg_color == PRCOLOR_BLACK)
3790- bg_color = PRCOLOR_WHITE;
3791-
3792- fg_color = highlight_gui_color_rgb(hl_id, TRUE);
3793- }
3794- else
3795-# endif
3796- {
3797- bg_color = PRCOLOR_WHITE;
3798-
3799- color = (char *)highlight_color(hl_id, (char_u *)"fg", modec);
3800- if (color == NULL)
3801- colorindex = 0;
3802- else
3803- colorindex = atoi(color);
3804-
3805- if (colorindex >= 0 && colorindex < t_colors)
3806- fg_color = prt_get_term_color(colorindex);
3807- else
3808- fg_color = PRCOLOR_BLACK;
3809- }
3810-
3811- if (fg_color == PRCOLOR_WHITE)
3812- fg_color = PRCOLOR_BLACK;
3813- else if (*p_bg == 'd')
3814- fg_color = darken_rgb(fg_color);
3815-
3816- pattr->fg_color = fg_color;
3817- pattr->bg_color = bg_color;
3818-}
3819-#endif /* FEAT_SYN_HL */
3820-
3821- static void
3822-prt_set_fg(fg)
3823- long_u fg;
3824-{
3825- if (fg != curr_fg)
3826- {
3827- curr_fg = fg;
3828- mch_print_set_fg(fg);
3829- }
3830-}
3831-
3832- static void
3833-prt_set_bg(bg)
3834- long_u bg;
3835-{
3836- if (bg != curr_bg)
3837- {
3838- curr_bg = bg;
3839- mch_print_set_bg(bg);
3840- }
3841-}
3842-
3843- static void
3844-prt_set_font(bold, italic, underline)
3845- int bold;
3846- int italic;
3847- int underline;
3848-{
3849- if (curr_bold != bold
3850- || curr_italic != italic
3851- || curr_underline != underline)
3852- {
3853- curr_underline = underline;
3854- curr_italic = italic;
3855- curr_bold = bold;
3856- mch_print_set_font(bold, italic, underline);
3857- }
3858-}
3859-
3860-/*
3861- * Print the line number in the left margin.
3862- */
3863- static void
3864-prt_line_number(psettings, page_line, lnum)
3865- prt_settings_T *psettings;
3866- int page_line;
3867- linenr_T lnum;
3868-{
3869- int i;
3870- char_u tbuf[20];
3871-
3872- prt_set_fg(psettings->number.fg_color);
3873- prt_set_bg(psettings->number.bg_color);
3874- prt_set_font(psettings->number.bold, psettings->number.italic, psettings->number.underline);
3875- mch_print_start_line(TRUE, page_line);
3876-
3877- /* Leave two spaces between the number and the text; depends on
3878- * PRINT_NUMBER_WIDTH. */
3879- sprintf((char *)tbuf, "%6ld", (long)lnum);
3880- for (i = 0; i < 6; i++)
3881- (void)mch_print_text_out(&tbuf[i], 1);
3882-
3883-#ifdef FEAT_SYN_HL
3884- if (psettings->do_syntax)
3885- /* Set colors for next character. */
3886- current_syn_id = -1;
3887- else
3888-#endif
3889- {
3890- /* Set colors and font back to normal. */
3891- prt_set_fg(PRCOLOR_BLACK);
3892- prt_set_bg(PRCOLOR_WHITE);
3893- prt_set_font(FALSE, FALSE, FALSE);
3894- }
3895-}
3896-
3897-static linenr_T printer_page_num;
3898-
3899- int
3900-get_printer_page_num()
3901-{
3902- return printer_page_num;
3903-}
3904-
3905-/*
3906- * Get the currently effective header height.
3907- */
3908- int
3909-prt_header_height()
3910-{
3911- if (printer_opts[OPT_PRINT_HEADERHEIGHT].present)
3912- return printer_opts[OPT_PRINT_HEADERHEIGHT].number;
3913- return 2;
3914-}
3915-
3916-/*
3917- * Return TRUE if using a line number for printing.
3918- */
3919- int
3920-prt_use_number()
3921-{
3922- return (printer_opts[OPT_PRINT_NUMBER].present
3923- && TOLOWER_ASC(printer_opts[OPT_PRINT_NUMBER].string[0]) == 'y');
3924-}
3925-
3926-/*
3927- * Return the unit used in a margin item in 'printoptions'.
3928- * Returns PRT_UNIT_NONE if not recognized.
3929- */
3930- int
3931-prt_get_unit(idx)
3932- int idx;
3933-{
3934- int u = PRT_UNIT_NONE;
3935- int i;
3936- static char *(units[4]) = PRT_UNIT_NAMES;
3937-
3938- if (printer_opts[idx].present)
3939- for (i = 0; i < 4; ++i)
3940- if (STRNICMP(printer_opts[idx].string, units[i], 2) == 0)
3941- {
3942- u = i;
3943- break;
3944- }
3945- return u;
3946-}
3947-
3948-/*
3949- * Print the page header.
3950- */
3951-/*ARGSUSED*/
3952- static void
3953-prt_header(psettings, pagenum, lnum)
3954- prt_settings_T *psettings;
3955- int pagenum;
3956- linenr_T lnum;
3957-{
3958- int width = psettings->chars_per_line;
3959- int page_line;
3960- char_u *tbuf;
3961- char_u *p;
3962-#ifdef FEAT_MBYTE
3963- int l;
3964-#endif
3965-
3966- /* Also use the space for the line number. */
3967- if (prt_use_number())
3968- width += PRINT_NUMBER_WIDTH;
3969-
3970- tbuf = alloc(width + IOSIZE);
3971- if (tbuf == NULL)
3972- return;
3973-
3974-#ifdef FEAT_STL_OPT
3975- if (*p_header != NUL)
3976- {
3977- linenr_T tmp_lnum, tmp_topline, tmp_botline;
3978-
3979- /*
3980- * Need to (temporarily) set current line number and first/last line
3981- * number on the 'window'. Since we don't know how long the page is,
3982- * set the first and current line number to the top line, and guess
3983- * that the page length is 64.
3984- */
3985- tmp_lnum = curwin->w_cursor.lnum;
3986- tmp_topline = curwin->w_topline;
3987- tmp_botline = curwin->w_botline;
3988- curwin->w_cursor.lnum = lnum;
3989- curwin->w_topline = lnum;
3990- curwin->w_botline = lnum + 63;
3991- printer_page_num = pagenum;
3992-
3993- build_stl_str_hl(curwin, tbuf, (size_t)(width + IOSIZE),
3994- p_header, ' ', width, NULL);
3995-
3996- /* Reset line numbers */
3997- curwin->w_cursor.lnum = tmp_lnum;
3998- curwin->w_topline = tmp_topline;
3999- curwin->w_botline = tmp_botline;
4000- }
4001- else
4002-#endif
4003- sprintf((char *)tbuf, _("Page %d"), pagenum);
4004-
4005- prt_set_fg(PRCOLOR_BLACK);
4006- prt_set_bg(PRCOLOR_WHITE);
4007- prt_set_font(TRUE, FALSE, FALSE);
4008-
4009- /* Use a negative line number to indicate printing in the top margin. */
4010- page_line = 0 - prt_header_height();
4011- mch_print_start_line(TRUE, page_line);
4012- for (p = tbuf; *p != NUL; )
4013- {
4014- if (mch_print_text_out(p,
4015-#ifdef FEAT_MBYTE
4016- (l = (*mb_ptr2len_check)(p))
4017-#else
4018- 1
4019-#endif
4020- ))
4021- {
4022- ++page_line;
4023- if (page_line >= 0) /* out of room in header */
4024- break;
4025- mch_print_start_line(TRUE, page_line);
4026- }
4027-#ifdef FEAT_MBYTE
4028- p += l;
4029-#else
4030- p++;
4031-#endif
4032- }
4033-
4034- vim_free(tbuf);
4035-
4036-#ifdef FEAT_SYN_HL
4037- if (psettings->do_syntax)
4038- /* Set colors for next character. */
4039- current_syn_id = -1;
4040- else
4041-#endif
4042- {
4043- /* Set colors and font back to normal. */
4044- prt_set_fg(PRCOLOR_BLACK);
4045- prt_set_bg(PRCOLOR_WHITE);
4046- prt_set_font(FALSE, FALSE, FALSE);
4047- }
4048-}
4049-
4050-/*
4051- * Display a print status message.
4052- */
4053- static void
4054-prt_message(s)
4055- char_u *s;
4056-{
4057- screen_fill((int)Rows - 1, (int)Rows, 0, (int)Columns, ' ', ' ', 0);
4058- screen_puts(s, (int)Rows - 1, 0, hl_attr(HLF_R));
4059- out_flush();
4060-}
4061-
4062- void
4063-ex_hardcopy(eap)
4064- exarg_T *eap;
4065-{
4066- linenr_T lnum;
4067- int collated_copies, uncollated_copies;
4068- prt_settings_T settings;
4069- long_u bytes_to_print = 0;
4070- int page_line;
4071- int jobsplit;
4072- int id;
4073-
4074- memset(&settings, 0, sizeof(prt_settings_T));
4075- settings.has_color = TRUE;
4076-
4077-# ifdef FEAT_POSTSCRIPT
4078- if (*eap->arg == '>')
4079- {
4080- char_u *errormsg = NULL;
4081-
4082- /* Expand things like "%.ps". */
4083- if (expand_filename(eap, eap->cmdlinep, &errormsg) == FAIL)
4084- {
4085- if (errormsg != NULL)
4086- EMSG(errormsg);
4087- return;
4088- }
4089- settings.outfile = skipwhite(eap->arg + 1);
4090- }
4091- else if (*eap->arg != NUL)
4092- settings.arguments = eap->arg;
4093-# endif
4094-
4095- /*
4096- * Initialise for printing. Ask the user for settings, unless forceit is
4097- * set.
4098- * The mch_print_init() code should set up margins if applicable. (It may
4099- * not be a real printer - for example the engine might generate HTML or
4100- * PS.)
4101- */
4102- if (mch_print_init(&settings,
4103- curbuf->b_fname == NULL
4104- ? (char_u *)buf_spname(curbuf)
4105- : curbuf->b_sfname == NULL
4106- ? curbuf->b_fname
4107- : curbuf->b_sfname,
4108- eap->forceit) == FAIL)
4109- return;
4110-
4111-#ifdef FEAT_SYN_HL
4112-# ifdef FEAT_GUI
4113- if (gui.in_use)
4114- settings.modec = 'g';
4115- else
4116-# endif
4117- if (t_colors > 1)
4118- settings.modec = 'c';
4119- else
4120- settings.modec = 't';
4121-
4122- if (!syntax_present(curbuf))
4123- settings.do_syntax = FALSE;
4124- else if (printer_opts[OPT_PRINT_SYNTAX].present
4125- && TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) != 'a')
4126- settings.do_syntax =
4127- (TOLOWER_ASC(printer_opts[OPT_PRINT_SYNTAX].string[0]) == 'y');
4128- else
4129- settings.do_syntax = settings.has_color;
4130-#endif
4131-
4132- /* Set up printing attributes for line numbers */
4133- settings.number.fg_color = PRCOLOR_BLACK;
4134- settings.number.bg_color = PRCOLOR_WHITE;
4135- settings.number.bold = FALSE;
4136- settings.number.italic = TRUE;
4137- settings.number.underline = FALSE;
4138-#ifdef FEAT_SYN_HL
4139- /*
4140- * Syntax highlighting of line numbers.
4141- */
4142- if (prt_use_number() && settings.do_syntax)
4143- {
4144- id = syn_name2id((char_u *)"LineNr");
4145- if (id > 0)
4146- id = syn_get_final_id(id);
4147-
4148- prt_get_attr(id, &settings.number, settings.modec);
4149- }
4150-#endif /* FEAT_SYN_HL */
4151-
4152- /*
4153- * Estimate the total lines to be printed
4154- */
4155- for (lnum = eap->line1; lnum <= eap->line2; lnum++)
4156- bytes_to_print += (long_u)STRLEN(skipwhite(ml_get(lnum)));
4157- if (bytes_to_print == 0)
4158- {
4159- MSG(_("No text to be printed"));
4160- goto print_fail_no_begin;
4161- }
4162-
4163- /* Set colors and font to normal. */
4164- curr_bg = (long_u)0xffffffffL;
4165- curr_fg = (long_u)0xffffffffL;
4166- curr_italic = MAYBE;
4167- curr_bold = MAYBE;
4168- curr_underline = MAYBE;
4169-
4170- prt_set_fg(PRCOLOR_BLACK);
4171- prt_set_bg(PRCOLOR_WHITE);
4172- prt_set_font(FALSE, FALSE, FALSE);
4173-#ifdef FEAT_SYN_HL
4174- current_syn_id = -1;
4175-#endif
4176-
4177- jobsplit = (printer_opts[OPT_PRINT_JOBSPLIT].present
4178- && TOLOWER_ASC(printer_opts[OPT_PRINT_JOBSPLIT].string[0]) == 'y');
4179-
4180- if (!mch_print_begin(&settings))
4181- goto print_fail_no_begin;
4182-
4183- /*
4184- * Loop over collated copies: 1 2 3, 1 2 3, ...
4185- */
4186- page_count = 0;
4187- for (collated_copies = 0;
4188- collated_copies < settings.n_collated_copies;
4189- collated_copies++)
4190- {
4191- prt_pos_T prtpos; /* current print position */
4192- prt_pos_T page_prtpos; /* print position at page start */
4193- int side;
4194-
4195- memset(&page_prtpos, 0, sizeof(prt_pos_T));
4196- page_prtpos.file_line = eap->line1;
4197- prtpos = page_prtpos;
4198-
4199- if (jobsplit && collated_copies > 0)
4200- {
4201- /* Splitting jobs: Stop a previous job and start a new one. */
4202- mch_print_end(&settings);
4203- if (!mch_print_begin(&settings))
4204- goto print_fail_no_begin;
4205- }
4206-
4207- /*
4208- * Loop over all pages in the print job: 1 2 3 ...
4209- */
4210- for (page_count = 0; prtpos.file_line <= eap->line2; ++page_count)
4211- {
4212- /*
4213- * Loop over uncollated copies: 1 1 1, 2 2 2, 3 3 3, ...
4214- * For duplex: 12 12 12 34 34 34, ...
4215- */
4216- for (uncollated_copies = 0;
4217- uncollated_copies < settings.n_uncollated_copies;
4218- uncollated_copies++)
4219- {
4220- /* Set the print position to the start of this page. */
4221- prtpos = page_prtpos;
4222-
4223- /*
4224- * Do front and rear side of a page.
4225- */
4226- for (side = 0; side <= settings.duplex; ++side)
4227- {
4228- /*
4229- * Print one page.
4230- */
4231-
4232- /* Check for interrupt character every page. */
4233- ui_breakcheck();
4234- if (got_int || settings.user_abort)
4235- goto print_fail;
4236-
4237- sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
4238- page_count + 1 + side,
4239- prtpos.bytes_printed > 1000000
4240- ? (int)(prtpos.bytes_printed /
4241- (bytes_to_print / 100))
4242- : (int)((prtpos.bytes_printed * 100)
4243- / bytes_to_print));
4244- if (!mch_print_begin_page(IObuff))
4245- goto print_fail;
4246-
4247- if (settings.n_collated_copies > 1)
4248- sprintf((char *)IObuff + STRLEN(IObuff),
4249- _(" Copy %d of %d"),
4250- collated_copies + 1,
4251- settings.n_collated_copies);
4252- prt_message(IObuff);
4253-
4254- /*
4255- * Output header if required
4256- */
4257- if (prt_header_height() > 0)
4258- prt_header(&settings, page_count + 1 + side,
4259- prtpos.file_line);
4260-
4261- for (page_line = 0; page_line < settings.lines_per_page;
4262- ++page_line)
4263- {
4264- prtpos.column = hardcopy_line(&settings,
4265- page_line, &prtpos);
4266- if (prtpos.column == 0)
4267- {
4268- /* finished a file line */
4269- prtpos.bytes_printed +=
4270- STRLEN(skipwhite(ml_get(prtpos.file_line)));
4271- if (++prtpos.file_line > eap->line2)
4272- break; /* reached the end */
4273- }
4274- else if (prtpos.ff)
4275- {
4276- /* Line had a formfeed in it - start new page but
4277- * stay on the current line */
4278- break;
4279- }
4280- }
4281-
4282- if (!mch_print_end_page())
4283- goto print_fail;
4284- if (prtpos.file_line > eap->line2)
4285- break; /* reached the end */
4286- }
4287-
4288- /*
4289- * Extra blank page for duplexing with odd number of pages and
4290- * more copies to come.
4291- */
4292- if (prtpos.file_line > eap->line2 && settings.duplex
4293- && side == 0
4294- && uncollated_copies + 1 < settings.n_uncollated_copies)
4295- {
4296- if (!mch_print_blank_page())
4297- goto print_fail;
4298- }
4299- }
4300- if (settings.duplex && prtpos.file_line <= eap->line2)
4301- ++page_count;
4302-
4303- /* Remember the position where the next page starts. */
4304- page_prtpos = prtpos;
4305- }
4306-
4307- vim_snprintf((char *)IObuff, IOSIZE, _("Printed: %s"),
4308- settings.jobname);
4309- prt_message(IObuff);
4310- }
4311-
4312-print_fail:
4313- if (got_int || settings.user_abort)
4314- {
4315- sprintf((char *)IObuff, "%s", _("Printing aborted"));
4316- prt_message(IObuff);
4317- }
4318- mch_print_end(&settings);
4319-
4320-print_fail_no_begin:
4321- mch_print_cleanup();
4322-}
4323-
4324-/*
4325- * Print one page line.
4326- * Return the next column to print, or zero if the line is finished.
4327- */
4328- static colnr_T
4329-hardcopy_line(psettings, page_line, ppos)
4330- prt_settings_T *psettings;
4331- int page_line;
4332- prt_pos_T *ppos;
4333-{
4334- colnr_T col;
4335- char_u *line;
4336- int need_break = FALSE;
4337- int outputlen;
4338- int tab_spaces;
4339- long_u print_pos;
4340-#ifdef FEAT_SYN_HL
4341- prt_text_attr_T attr;
4342- int id;
4343-#endif
4344-
4345- if (ppos->column == 0 || ppos->ff)
4346- {
4347- print_pos = 0;
4348- tab_spaces = 0;
4349- if (!ppos->ff && prt_use_number())
4350- prt_line_number(psettings, page_line, ppos->file_line);
4351- ppos->ff = FALSE;
4352- }
4353- else
4354- {
4355- /* left over from wrap halfway a tab */
4356- print_pos = ppos->print_pos;
4357- tab_spaces = ppos->lead_spaces;
4358- }
4359-
4360- mch_print_start_line(0, page_line);
4361- line = ml_get(ppos->file_line);
4362-
4363- /*
4364- * Loop over the columns until the end of the file line or right margin.
4365- */
4366- for (col = ppos->column; line[col] != NUL && !need_break; col += outputlen)
4367- {
4368- outputlen = 1;
4369-#ifdef FEAT_MBYTE
4370- if (has_mbyte && (outputlen = (*mb_ptr2len_check)(line + col)) < 1)
4371- outputlen = 1;
4372-#endif
4373-#ifdef FEAT_SYN_HL
4374- /*
4375- * syntax highlighting stuff.
4376- */
4377- if (psettings->do_syntax)
4378- {
4379- id = syn_get_id(ppos->file_line, col, 1, NULL);
4380- if (id > 0)
4381- id = syn_get_final_id(id);
4382- else
4383- id = 0;
4384- /* Get the line again, a multi-line regexp may invalidate it. */
4385- line = ml_get(ppos->file_line);
4386-
4387- if (id != current_syn_id)
4388- {
4389- current_syn_id = id;
4390- prt_get_attr(id, &attr, psettings->modec);
4391- prt_set_font(attr.bold, attr.italic, attr.underline);
4392- prt_set_fg(attr.fg_color);
4393- prt_set_bg(attr.bg_color);
4394- }
4395- }
4396-#endif /* FEAT_SYN_HL */
4397-
4398- /*
4399- * Appropriately expand any tabs to spaces.
4400- */
4401- if (line[col] == TAB || tab_spaces != 0)
4402- {
4403- if (tab_spaces == 0)
4404- tab_spaces = curbuf->b_p_ts - (print_pos % curbuf->b_p_ts);
4405-
4406- while (tab_spaces > 0)
4407- {
4408- need_break = mch_print_text_out((char_u *)" ", 1);
4409- print_pos++;
4410- tab_spaces--;
4411- if (need_break)
4412- break;
4413- }
4414- /* Keep the TAB if we didn't finish it. */
4415- if (need_break && tab_spaces > 0)
4416- break;
4417- }
4418- else if (line[col] == FF
4419- && printer_opts[OPT_PRINT_FORMFEED].present
4420- && TOLOWER_ASC(printer_opts[OPT_PRINT_FORMFEED].string[0])
4421- == 'y')
4422- {
4423- ppos->ff = TRUE;
4424- need_break = 1;
4425- }
4426- else
4427- {
4428- need_break = mch_print_text_out(line + col, outputlen);
4429-#ifdef FEAT_MBYTE
4430- if (has_mbyte)
4431- print_pos += (*mb_ptr2cells)(line + col);
4432- else
4433-#endif
4434- print_pos++;
4435- }
4436- }
4437-
4438- ppos->lead_spaces = tab_spaces;
4439- ppos->print_pos = print_pos;
4440-
4441- /*
4442- * Start next line of file if we clip lines, or have reached end of the
4443- * line, unless we are doing a formfeed.
4444- */
4445- if (!ppos->ff
4446- && (line[col] == NUL
4447- || (printer_opts[OPT_PRINT_WRAP].present
4448- && TOLOWER_ASC(printer_opts[OPT_PRINT_WRAP].string[0])
4449- == 'n')))
4450- return 0;
4451- return col;
4452-}
4453-
4454-# if defined(FEAT_POSTSCRIPT) || defined(PROTO)
4455-
4456-/*
4457- * PS printer stuff.
4458- *
4459- * Sources of information to help maintain the PS printing code:
4460- *
4461- * 1. PostScript Language Reference, 3rd Edition,
4462- * Addison-Wesley, 1999, ISBN 0-201-37922-8
4463- * 2. PostScript Language Program Design,
4464- * Addison-Wesley, 1988, ISBN 0-201-14396-8
4465- * 3. PostScript Tutorial and Cookbook,
4466- * Addison Wesley, 1985, ISBN 0-201-10179-3
4467- * 4. PostScript Language Document Structuring Conventions Specification,
4468- * version 3.0,
4469- * Adobe Technote 5001, 25th September 1992
4470- * 5. PostScript Printer Description File Format Specification, Version 4.3,
4471- * Adobe technote 5003, 9th February 1996
4472- * 6. Adobe Font Metrics File Format Specification, Version 4.1,
4473- * Adobe Technote 5007, 7th October 1998
4474- * 7. Adobe CMap and CIDFont Files Specification, Version 1.0,
4475- * Adobe Technote 5014, 8th October 1996
4476- * 8. Adobe CJKV Character Collections and CMaps for CID-Keyed Fonts,
4477- * Adoboe Technote 5094, 8th September, 2001
4478- * 9. CJKV Information Processing, 2nd Edition,
4479- * O'Reilly, 2002, ISBN 1-56592-224-7
4480- *
4481- * Some of these documents can be found in PDF form on Adobe's web site -
4482- * http://www.adobe.com
4483- */
4484-
4485-#define NUM_ELEMENTS(arr) (sizeof(arr)/sizeof((arr)[0]))
4486-
4487-#define PRT_PS_DEFAULT_DPI (72) /* Default user space resolution */
4488-#define PRT_PS_DEFAULT_FONTSIZE (10)
4489-#define PRT_PS_DEFAULT_BUFFER_SIZE (80)
4490-
4491-struct prt_mediasize_S
4492-{
4493- char *name;
4494- float width; /* width and height in points for portrait */
4495- float height;
4496-};
4497-
4498-#define PRT_MEDIASIZE_LEN (sizeof(prt_mediasize) / sizeof(struct prt_mediasize_S))
4499-
4500-static struct prt_mediasize_S prt_mediasize[] =
4501-{
4502- {"A4", 595.0, 842.0},
4503- {"letter", 612.0, 792.0},
4504- {"10x14", 720.0, 1008.0},
4505- {"A3", 842.0, 1191.0},
4506- {"A5", 420.0, 595.0},
4507- {"B4", 729.0, 1032.0},
4508- {"B5", 516.0, 729.0},
4509- {"executive", 522.0, 756.0},
4510- {"folio", 595.0, 935.0},
4511- {"ledger", 1224.0, 792.0}, /* Yes, it is wider than taller! */
4512- {"legal", 612.0, 1008.0},
4513- {"quarto", 610.0, 780.0},
4514- {"statement", 396.0, 612.0},
4515- {"tabloid", 792.0, 1224.0}
4516-};
4517-
4518-/* PS font names, must be in Roman, Bold, Italic, Bold-Italic order */
4519-struct prt_ps_font_S
4520-{
4521- int wx;
4522- int uline_offset;
4523- int uline_width;
4524- int bbox_min_y;
4525- int bbox_max_y;
4526- char *(ps_fontname[4]);
4527-};
4528-
4529-#define PRT_PS_FONT_ROMAN (0)
4530-#define PRT_PS_FONT_BOLD (1)
4531-#define PRT_PS_FONT_OBLIQUE (2)
4532-#define PRT_PS_FONT_BOLDOBLIQUE (3)
4533-
4534-/* Standard font metrics for Courier family */
4535-static struct prt_ps_font_S prt_ps_courier_font =
4536-{
4537- 600,
4538- -100, 50,
4539- -250, 805,
4540- {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}
4541-};
4542-
4543-#ifdef FEAT_MBYTE
4544-/* Generic font metrics for multi-byte fonts */
4545-static struct prt_ps_font_S prt_ps_mb_font =
4546-{
4547- 1000,
4548- -100, 50,
4549- -250, 805,
4550- {NULL, NULL, NULL, NULL}
4551-};
4552-#endif
4553-
4554-/* Pointer to current font set being used */
4555-static struct prt_ps_font_S* prt_ps_font;
4556-
4557-/* Structures to map user named encoding and mapping to PS equivalents for
4558- * building CID font name */
4559-struct prt_ps_encoding_S
4560-{
4561- char *encoding;
4562- char *cmap_encoding;
4563- int needs_charset;
4564-};
4565-
4566-struct prt_ps_charset_S
4567-{
4568- char *charset;
4569- char *cmap_charset;
4570- int has_charset;
4571-};
4572-
4573-#ifdef FEAT_MBYTE
4574-
4575-#define CS_JIS_C_1978 (0x01)
4576-#define CS_JIS_X_1983 (0x02)
4577-#define CS_JIS_X_1990 (0x04)
4578-#define CS_NEC (0x08)
4579-#define CS_MSWINDOWS (0x10)
4580-#define CS_CP932 (0x20)
4581-#define CS_KANJITALK6 (0x40)
4582-#define CS_KANJITALK7 (0x80)
4583-
4584-/* Japanese encodings and charsets */
4585-static struct prt_ps_encoding_S j_encodings[] =
4586-{
4587- {"iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990|
4588- CS_NEC)},
4589- {"euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990)},
4590- {"sjis", "RKSJ", (CS_JIS_C_1978|CS_JIS_X_1983|CS_MSWINDOWS|
4591- CS_KANJITALK6|CS_KANJITALK7)},
4592- {"cp932", "RKSJ", CS_JIS_X_1983},
4593- {"ucs-2", "UCS2", CS_JIS_X_1990},
4594- {"utf-8", "UTF8" , CS_JIS_X_1990}
4595-};
4596-static struct prt_ps_charset_S j_charsets[] =
4597-{
4598- {"JIS_C_1978", "78", CS_JIS_C_1978},
4599- {"JIS_X_1983", NULL, CS_JIS_X_1983},
4600- {"JIS_X_1990", "Hojo", CS_JIS_X_1990},
4601- {"NEC", "Ext", CS_NEC},
4602- {"MSWINDOWS", "90ms", CS_MSWINDOWS},
4603- {"CP932", "90ms", CS_JIS_X_1983},
4604- {"KANJITALK6", "83pv", CS_KANJITALK6},
4605- {"KANJITALK7", "90pv", CS_KANJITALK7}
4606-};
4607-
4608-#define CS_GB_2312_80 (0x01)
4609-#define CS_GBT_12345_90 (0x02)
4610-#define CS_GBK2K (0x04)
4611-#define CS_SC_MAC (0x08)
4612-#define CS_GBT_90_MAC (0x10)
4613-#define CS_GBK (0x20)
4614-#define CS_SC_ISO10646 (0x40)
4615-
4616-/* Simplified Chinese encodings and charsets */
4617-static struct prt_ps_encoding_S sc_encodings[] =
4618-{
4619- {"iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90)},
4620- {"gb18030", NULL, CS_GBK2K},
4621- {"euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC|
4622- CS_GBT_90_MAC)},
4623- {"gbk", "EUC", CS_GBK},
4624- {"ucs-2", "UCS2", CS_SC_ISO10646},
4625- {"utf-8", "UTF8", CS_SC_ISO10646}
4626-};
4627-static struct prt_ps_charset_S sc_charsets[] =
4628-{
4629- {"GB_2312-80", "GB", CS_GB_2312_80},
4630- {"GBT_12345-90","GBT", CS_GBT_12345_90},
4631- {"MAC", "GBpc", CS_SC_MAC},
4632- {"GBT-90_MAC", "GBTpc", CS_GBT_90_MAC},
4633- {"GBK", "GBK", CS_GBK},
4634- {"GB18030", "GBK2K", CS_GBK2K},
4635- {"ISO10646", "UniGB", CS_SC_ISO10646}
4636-};
4637-
4638-#define CS_CNS_PLANE_1 (0x01)
4639-#define CS_CNS_PLANE_2 (0x02)
4640-#define CS_CNS_PLANE_1_2 (0x04)
4641-#define CS_B5 (0x08)
4642-#define CS_ETEN (0x10)
4643-#define CS_HK_GCCS (0x20)
4644-#define CS_HK_SCS (0x40)
4645-#define CS_HK_SCS_ETEN (0x80)
4646-#define CS_MTHKL (0x100)
4647-#define CS_MTHKS (0x200)
4648-#define CS_DLHKL (0x400)
4649-#define CS_DLHKS (0x800)
4650-#define CS_TC_ISO10646 (0x1000)
4651-
4652-/* Traditional Chinese encodings and charsets */
4653-static struct prt_ps_encoding_S tc_encodings[] =
4654-{
4655- {"iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2)},
4656- {"euc-tw", "EUC", CS_CNS_PLANE_1_2},
4657- {"big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS|
4658- CS_HK_SCS_ETEN|CS_MTHKL|CS_MTHKS|CS_DLHKL|
4659- CS_DLHKS)},
4660- {"cp950", "B5", CS_B5},
4661- {"ucs-2", "UCS2", CS_TC_ISO10646},
4662- {"utf-8", "UTF8", CS_TC_ISO10646},
4663- {"utf-16", "UTF16", CS_TC_ISO10646},
4664- {"utf-32", "UTF32", CS_TC_ISO10646}
4665-};
4666-static struct prt_ps_charset_S tc_charsets[] =
4667-{
4668- {"CNS_1992_1", "CNS1", CS_CNS_PLANE_1},
4669- {"CNS_1992_2", "CNS2", CS_CNS_PLANE_2},
4670- {"CNS_1993", "CNS", CS_CNS_PLANE_1_2},
4671- {"BIG5", NULL, CS_B5},
4672- {"CP950", NULL, CS_B5},
4673- {"ETEN", "ETen", CS_ETEN},
4674- {"HK_GCCS", "HKgccs", CS_HK_GCCS},
4675- {"SCS", "HKscs", CS_HK_SCS},
4676- {"SCS_ETEN", "ETHK", CS_HK_SCS_ETEN},
4677- {"MTHKL", "HKm471", CS_MTHKL},
4678- {"MTHKS", "HKm314", CS_MTHKS},
4679- {"DLHKL", "HKdla", CS_DLHKL},
4680- {"DLHKS", "HKdlb", CS_DLHKS},
4681- {"ISO10646", "UniCNS", CS_TC_ISO10646}
4682-};
4683-
4684-#define CS_KR_X_1992 (0x01)
4685-#define CS_KR_MAC (0x02)
4686-#define CS_KR_X_1992_MS (0x04)
4687-#define CS_KR_ISO10646 (0x08)
4688-
4689-/* Korean encodings and charsets */
4690-static struct prt_ps_encoding_S k_encodings[] =
4691-{
4692- {"iso-2022-kr", NULL, CS_KR_X_1992},
4693- {"euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC)},
4694- {"johab", "Johab", CS_KR_X_1992},
4695- {"cp1361", "Johab", CS_KR_X_1992},
4696- {"uhc", "UHC", CS_KR_X_1992_MS},
4697- {"cp949", "UHC", CS_KR_X_1992_MS},
4698- {"ucs-2", "UCS2", CS_KR_ISO10646},
4699- {"utf-8", "UTF8", CS_KR_ISO10646}
4700-};
4701-static struct prt_ps_charset_S k_charsets[] =
4702-{
4703- {"KS_X_1992", "KSC", CS_KR_X_1992},
4704- {"CP1361", "KSC", CS_KR_X_1992},
4705- {"MAC", "KSCpc", CS_KR_MAC},
4706- {"MSWINDOWS", "KSCms", CS_KR_X_1992_MS},
4707- {"CP949", "KSCms", CS_KR_X_1992_MS},
4708- {"WANSUNG", "KSCms", CS_KR_X_1992_MS},
4709- {"ISO10646", "UniKS", CS_KR_ISO10646}
4710-};
4711-
4712-/* Collections of encodings and charsets for multi-byte printing */
4713-struct prt_ps_mbfont_S
4714-{
4715- int num_encodings;
4716- struct prt_ps_encoding_S *encodings;
4717- int num_charsets;
4718- struct prt_ps_charset_S *charsets;
4719- char *ascii_enc;
4720- char *defcs;
4721-};
4722-
4723-static struct prt_ps_mbfont_S prt_ps_mbfonts[] =
4724-{
4725- {
4726- NUM_ELEMENTS(j_encodings),
4727- j_encodings,
4728- NUM_ELEMENTS(j_charsets),
4729- j_charsets,
4730- "jis_roman",
4731- "JIS_X_1983"
4732- },
4733- {
4734- NUM_ELEMENTS(sc_encodings),
4735- sc_encodings,
4736- NUM_ELEMENTS(sc_charsets),
4737- sc_charsets,
4738- "gb_roman",
4739- "GB_2312-80"
4740- },
4741- {
4742- NUM_ELEMENTS(tc_encodings),
4743- tc_encodings,
4744- NUM_ELEMENTS(tc_charsets),
4745- tc_charsets,
4746- "cns_roman",
4747- "BIG5"
4748- },
4749- {
4750- NUM_ELEMENTS(k_encodings),
4751- k_encodings,
4752- NUM_ELEMENTS(k_charsets),
4753- k_charsets,
4754- "ks_roman",
4755- "KS_X_1992"
4756- }
4757-};
4758-#endif /* FEAT_MBYTE */
4759-
4760-struct prt_ps_resource_S
4761-{
4762- char_u name[64];
4763- char_u filename[MAXPATHL + 1];
4764- int type;
4765- char_u title[256];
4766- char_u version[256];
4767-};
4768-
4769-/* Types of PS resource file currently used */
4770-#define PRT_RESOURCE_TYPE_PROCSET (0)
4771-#define PRT_RESOURCE_TYPE_ENCODING (1)
4772-#define PRT_RESOURCE_TYPE_CMAP (2)
4773-
4774-/* The PS prolog file version number has to match - if the prolog file is
4775- * updated, increment the number in the file and here. Version checking was
4776- * added as of VIM 6.2.
4777- * The CID prolog file version number behaves as per PS prolog.
4778- * Table of VIM and prolog versions:
4779- *
4780- * VIM Prolog CIDProlog
4781- * 6.2 1.3
4782- * 7.0 1.4 1.0
4783- */
4784-#define PRT_PROLOG_VERSION ((char_u *)"1.4")
4785-#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0")
4786-
4787-/* String versions of PS resource types - indexed by constants above so don't
4788- * re-order!
4789- */
4790-static char *prt_resource_types[] =
4791-{
4792- "procset",
4793- "encoding",
4794- "cmap"
4795-};
4796-
4797-/* Strings to look for in a PS resource file */
4798-#define PRT_RESOURCE_HEADER "%!PS-Adobe-"
4799-#define PRT_RESOURCE_RESOURCE "Resource-"
4800-#define PRT_RESOURCE_PROCSET "ProcSet"
4801-#define PRT_RESOURCE_ENCODING "Encoding"
4802-#define PRT_RESOURCE_CMAP "CMap"
4803-
4804-
4805-/* Data for table based DSC comment recognition, easy to extend if VIM needs to
4806- * read more comments. */
4807-#define PRT_DSC_MISC_TYPE (-1)
4808-#define PRT_DSC_TITLE_TYPE (1)
4809-#define PRT_DSC_VERSION_TYPE (2)
4810-#define PRT_DSC_ENDCOMMENTS_TYPE (3)
4811-
4812-#define PRT_DSC_TITLE "%%Title:"
4813-#define PRT_DSC_VERSION "%%Version:"
4814-#define PRT_DSC_ENDCOMMENTS "%%EndComments:"
4815-
4816-struct prt_dsc_comment_S
4817-{
4818- char *string;
4819- int len;
4820- int type;
4821-};
4822-
4823-struct prt_dsc_line_S
4824-{
4825- int type;
4826- char_u *string;
4827- int len;
4828-};
4829-
4830-
4831-#define SIZEOF_CSTR(s) (sizeof(s) - 1)
4832-static struct prt_dsc_comment_S prt_dsc_table[] =
4833-{
4834- {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE},
4835- {PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION),
4836- PRT_DSC_VERSION_TYPE},
4837- {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS),
4838- PRT_DSC_ENDCOMMENTS_TYPE}
4839-};
4840-
4841-static void prt_write_file_raw_len __ARGS((char_u *buffer, int bytes));
4842-static void prt_write_file __ARGS((char_u *buffer));
4843-static void prt_write_file_len __ARGS((char_u *buffer, int bytes));
4844-static void prt_write_string __ARGS((char *s));
4845-static void prt_write_int __ARGS((int i));
4846-static void prt_write_boolean __ARGS((int b));
4847-static void prt_def_font __ARGS((char *new_name, char *encoding, int height, char *font));
4848-static void prt_real_bits __ARGS((double real, int precision, int *pinteger, int *pfraction));
4849-static void prt_write_real __ARGS((double val, int prec));
4850-static void prt_def_var __ARGS((char *name, double value, int prec));
4851-static void prt_flush_buffer __ARGS((void));
4852-static void prt_resource_name __ARGS((char_u *filename, void *cookie));
4853-static int prt_find_resource __ARGS((char *name, struct prt_ps_resource_S *resource));
4854-static int prt_open_resource __ARGS((struct prt_ps_resource_S *resource));
4855-static int prt_check_resource __ARGS((struct prt_ps_resource_S *resource, char_u *version));
4856-static void prt_dsc_start __ARGS((void));
4857-static void prt_dsc_noarg __ARGS((char *comment));
4858-static void prt_dsc_textline __ARGS((char *comment, char *text));
4859-static void prt_dsc_text __ARGS((char *comment, char *text));
4860-static void prt_dsc_ints __ARGS((char *comment, int count, int *ints));
4861-static void prt_dsc_requirements __ARGS((int duplex, int tumble, int collate, int color, int num_copies));
4862-static void prt_dsc_docmedia __ARGS((char *paper_name, double width, double height, double weight, char *colour, char *type));
4863-static void prt_dsc_resources __ARGS((char *comment, char *type, char *strings));
4864-static void prt_dsc_font_resource __ARGS((char *resource, struct prt_ps_font_S *ps_font));
4865-static float to_device_units __ARGS((int idx, double physsize, int def_number));
4866-static void prt_page_margins __ARGS((double width, double height, double *left, double *right, double *top, double *bottom));
4867-static void prt_font_metrics __ARGS((int font_scale));
4868-static int prt_get_cpl __ARGS((void));
4869-static int prt_get_lpp __ARGS((void));
4870-static int prt_add_resource __ARGS((struct prt_ps_resource_S *resource));
4871-static int prt_resfile_next_line __ARGS((void));
4872-static int prt_resfile_strncmp __ARGS((int offset, char *string, int len));
4873-static int prt_resfile_skip_nonws __ARGS((int offset));
4874-static int prt_resfile_skip_ws __ARGS((int offset));
4875-static int prt_next_dsc __ARGS((struct prt_dsc_line_S *p_dsc_line));
4876-#ifdef FEAT_MBYTE
4877-static int prt_build_cid_fontname __ARGS((int font, char_u *name, int name_len));
4878-static void prt_def_cidfont __ARGS((char *new_name, int height, char *cidfont));
4879-static void prt_dup_cidfont __ARGS((char *original_name, char *new_name));
4880-static int prt_match_encoding __ARGS((char *p_encoding, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_encoding_S **pp_mbenc));
4881-static int prt_match_charset __ARGS((char *p_charset, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_charset_S **pp_mbchar));
4882-#endif
4883-
4884-/*
4885- * Variables for the output PostScript file.
4886- */
4887-static FILE *prt_ps_fd;
4888-static int prt_file_error;
4889-static char_u *prt_ps_file_name = NULL;
4890-
4891-/*
4892- * Various offsets and dimensions in default PostScript user space (points).
4893- * Used for text positioning calculations
4894- */
4895-static float prt_page_width;
4896-static float prt_page_height;
4897-static float prt_left_margin;
4898-static float prt_right_margin;
4899-static float prt_top_margin;
4900-static float prt_bottom_margin;
4901-static float prt_line_height;
4902-static float prt_first_line_height;
4903-static float prt_char_width;
4904-static float prt_number_width;
4905-static float prt_bgcol_offset;
4906-static float prt_pos_x_moveto = 0.0;
4907-static float prt_pos_y_moveto = 0.0;
4908-
4909-/*
4910- * Various control variables used to decide when and how to change the
4911- * PostScript graphics state.
4912- */
4913-static int prt_need_moveto;
4914-static int prt_do_moveto;
4915-static int prt_need_font;
4916-static int prt_font;
4917-static int prt_need_underline;
4918-static int prt_underline;
4919-static int prt_do_underline;
4920-static int prt_need_fgcol;
4921-static int prt_fgcol;
4922-static int prt_need_bgcol;
4923-static int prt_do_bgcol;
4924-static int prt_bgcol;
4925-static int prt_new_bgcol;
4926-static int prt_attribute_change;
4927-static float prt_text_run;
4928-static int prt_page_num;
4929-static int prt_bufsiz;
4930-
4931-/*
4932- * Variables controlling physical printing.
4933- */
4934-static int prt_media;
4935-static int prt_portrait;
4936-static int prt_num_copies;
4937-static int prt_duplex;
4938-static int prt_tumble;
4939-static int prt_collate;
4940-
4941-/*
4942- * Buffers used when generating PostScript output
4943- */
4944-static char_u prt_line_buffer[257];
4945-static garray_T prt_ps_buffer;
4946-
4947-# ifdef FEAT_MBYTE
4948-static int prt_do_conv;
4949-static vimconv_T prt_conv;
4950-
4951-static int prt_out_mbyte;
4952-static int prt_custom_cmap;
4953-static char prt_cmap[80];
4954-static int prt_use_courier;
4955-static int prt_in_ascii;
4956-static int prt_half_width;
4957-static char *prt_ascii_encoding;
4958-static char_u prt_hexchar[] = "0123456789abcdef";
4959-# endif
4960-
4961- static void
4962-prt_write_file_raw_len(buffer, bytes)
4963- char_u *buffer;
4964- int bytes;
4965-{
4966- if (!prt_file_error
4967- && fwrite(buffer, sizeof(char_u), bytes, prt_ps_fd)
4968- != (size_t)bytes)
4969- {
4970- EMSG(_("E455: Error writing to PostScript output file"));
4971- prt_file_error = TRUE;
4972- }
4973-}
4974-
4975- static void
4976-prt_write_file(buffer)
4977- char_u *buffer;
4978-{
4979- prt_write_file_len(buffer, STRLEN(buffer));
4980-}
4981-
4982- static void
4983-prt_write_file_len(buffer, bytes)
4984- char_u *buffer;
4985- int bytes;
4986-{
4987-#ifdef EBCDIC
4988- ebcdic2ascii(buffer, bytes);
4989-#endif
4990- prt_write_file_raw_len(buffer, bytes);
4991-}
4992-
4993-/*
4994- * Write a string.
4995- */
4996- static void
4997-prt_write_string(s)
4998- char *s;
4999-{
5000- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer), "%s", s);
5001- prt_write_file(prt_line_buffer);
5002-}
5003-
5004-/*
5005- * Write an int and a space.
5006- */
5007- static void
5008-prt_write_int(i)
5009- int i;
5010-{
5011- sprintf((char *)prt_line_buffer, "%d ", i);
5012- prt_write_file(prt_line_buffer);
5013-}
5014-
5015-/*
5016- * Write a boolean and a space.
5017- */
5018- static void
5019-prt_write_boolean(b)
5020- int b;
5021-{
5022- sprintf((char *)prt_line_buffer, "%s ", (b ? "T" : "F"));
5023- prt_write_file(prt_line_buffer);
5024-}
5025-
5026-/*
5027- * Write PostScript to re-encode and define the font.
5028- */
5029- static void
5030-prt_def_font(new_name, encoding, height, font)
5031- char *new_name;
5032- char *encoding;
5033- int height;
5034- char *font;
5035-{
5036- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5037- "/_%s /VIM-%s /%s ref\n", new_name, encoding, font);
5038- prt_write_file(prt_line_buffer);
5039-#ifdef FEAT_MBYTE
5040- if (prt_out_mbyte)
5041- sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n",
5042- new_name, height, 500./prt_ps_courier_font.wx, new_name);
5043- else
5044-#endif
5045- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5046- "/%s %d /_%s ffs\n", new_name, height, new_name);
5047- prt_write_file(prt_line_buffer);
5048-}
5049-
5050-#ifdef FEAT_MBYTE
5051-/*
5052- * Write a line to define the CID font.
5053- */
5054- static void
5055-prt_def_cidfont(new_name, height, cidfont)
5056- char *new_name;
5057- int height;
5058- char *cidfont;
5059-{
5060- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5061- "/_%s /%s[/%s] vim_composefont\n", new_name, prt_cmap, cidfont);
5062- prt_write_file(prt_line_buffer);
5063- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5064- "/%s %d /_%s ffs\n", new_name, height, new_name);
5065- prt_write_file(prt_line_buffer);
5066-}
5067-
5068-/*
5069- * Write a line to define a duplicate of a CID font
5070- */
5071- static void
5072-prt_dup_cidfont(original_name, new_name)
5073- char *original_name;
5074- char *new_name;
5075-{
5076- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5077- "/%s %s d\n", new_name, original_name);
5078- prt_write_file(prt_line_buffer);
5079-}
5080-#endif
5081-
5082-/*
5083- * Convert a real value into an integer and fractional part as integers, with
5084- * the fractional part being in the range [0,10^precision). The fractional part
5085- * is also rounded based on the precision + 1'th fractional digit.
5086- */
5087- static void
5088-prt_real_bits(real, precision, pinteger, pfraction)
5089- double real;
5090- int precision;
5091- int *pinteger;
5092- int *pfraction;
5093-{
5094- int i;
5095- int integer;
5096- float fraction;
5097-
5098- integer = (int)real;
5099- fraction = (float)(real - integer);
5100- if (real < (double)integer)
5101- fraction = -fraction;
5102- for (i = 0; i < precision; i++)
5103- fraction *= 10.0;
5104-
5105- *pinteger = integer;
5106- *pfraction = (int)(fraction + 0.5);
5107-}
5108-
5109-/*
5110- * Write a real and a space. Save bytes if real value has no fractional part!
5111- * We use prt_real_bits() as %f in sprintf uses the locale setting to decide
5112- * what decimal point character to use, but PS always requires a '.'.
5113- */
5114- static void
5115-prt_write_real(val, prec)
5116- double val;
5117- int prec;
5118-{
5119- int integer;
5120- int fraction;
5121-
5122- prt_real_bits(val, prec, &integer, &fraction);
5123- /* Emit integer part */
5124- sprintf((char *)prt_line_buffer, "%d", integer);
5125- prt_write_file(prt_line_buffer);
5126- /* Only emit fraction if necessary */
5127- if (fraction != 0)
5128- {
5129- /* Remove any trailing zeros */
5130- while ((fraction % 10) == 0)
5131- {
5132- prec--;
5133- fraction /= 10;
5134- }
5135- /* Emit fraction left padded with zeros */
5136- sprintf((char *)prt_line_buffer, ".%0*d", prec, fraction);
5137- prt_write_file(prt_line_buffer);
5138- }
5139- sprintf((char *)prt_line_buffer, " ");
5140- prt_write_file(prt_line_buffer);
5141-}
5142-
5143-/*
5144- * Write a line to define a numeric variable.
5145- */
5146- static void
5147-prt_def_var(name, value, prec)
5148- char *name;
5149- double value;
5150- int prec;
5151-{
5152- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5153- "/%s ", name);
5154- prt_write_file(prt_line_buffer);
5155- prt_write_real(value, prec);
5156- sprintf((char *)prt_line_buffer, "d\n");
5157- prt_write_file(prt_line_buffer);
5158-}
5159-
5160-/* Convert size from font space to user space at current font scale */
5161-#define PRT_PS_FONT_TO_USER(scale, size) ((size) * ((scale)/1000.0))
5162-
5163- static void
5164-prt_flush_buffer()
5165-{
5166- if (prt_ps_buffer.ga_len > 0)
5167- {
5168- /* Any background color must be drawn first */
5169- if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE))
5170- {
5171- int r, g, b;
5172-
5173- if (prt_do_moveto)
5174- {
5175- prt_write_real(prt_pos_x_moveto, 2);
5176- prt_write_real(prt_pos_y_moveto, 2);
5177- prt_write_string("m\n");
5178- prt_do_moveto = FALSE;
5179- }
5180-
5181- /* Size of rect of background color on which text is printed */
5182- prt_write_real(prt_text_run, 2);
5183- prt_write_real(prt_line_height, 2);
5184-
5185- /* Lastly add the color of the background */
5186- r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
5187- g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
5188- b = prt_new_bgcol & 0xff;
5189- prt_write_real(r / 255.0, 3);
5190- prt_write_real(g / 255.0, 3);
5191- prt_write_real(b / 255.0, 3);
5192- prt_write_string("bg\n");
5193- }
5194- /* Draw underlines before the text as it makes it slightly easier to
5195- * find the starting point.
5196- */
5197- if (prt_do_underline)
5198- {
5199- if (prt_do_moveto)
5200- {
5201- prt_write_real(prt_pos_x_moveto, 2);
5202- prt_write_real(prt_pos_y_moveto, 2);
5203- prt_write_string("m\n");
5204- prt_do_moveto = FALSE;
5205- }
5206-
5207- /* Underline length of text run */
5208- prt_write_real(prt_text_run, 2);
5209- prt_write_string("ul\n");
5210- }
5211- /* Draw the text
5212- * Note: we write text out raw - EBCDIC conversion is handled in the
5213- * PostScript world via the font encoding vector. */
5214-#ifdef FEAT_MBYTE
5215- if (prt_out_mbyte)
5216- prt_write_string("<");
5217- else
5218-#endif
5219- prt_write_string("(");
5220- prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
5221-#ifdef FEAT_MBYTE
5222- if (prt_out_mbyte)
5223- prt_write_string(">");
5224- else
5225-#endif
5226- prt_write_string(")");
5227- /* Add a moveto if need be and use the appropriate show procedure */
5228- if (prt_do_moveto)
5229- {
5230- prt_write_real(prt_pos_x_moveto, 2);
5231- prt_write_real(prt_pos_y_moveto, 2);
5232- /* moveto and a show */
5233- prt_write_string("ms\n");
5234- prt_do_moveto = FALSE;
5235- }
5236- else /* Simple show */
5237- prt_write_string("s\n");
5238-
5239- ga_clear(&prt_ps_buffer);
5240- ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz);
5241- }
5242-}
5243-
5244-
5245- static void
5246-prt_resource_name(filename, cookie)
5247- char_u *filename;
5248- void *cookie;
5249-{
5250- char_u *resource_filename = cookie;
5251-
5252- if (STRLEN(filename) >= MAXPATHL)
5253- *resource_filename = NUL;
5254- else
5255- STRCPY(resource_filename, filename);
5256-}
5257-
5258- static int
5259-prt_find_resource(name, resource)
5260- char *name;
5261- struct prt_ps_resource_S *resource;
5262-{
5263- char_u buffer[MAXPATHL + 1];
5264-
5265- STRCPY(resource->name, name);
5266- /* Look for named resource file in runtimepath */
5267- STRCPY(buffer, "print");
5268- add_pathsep(buffer);
5269- STRCAT(buffer, name);
5270- STRCAT(buffer, ".ps");
5271- resource->filename[0] = NUL;
5272- return (do_in_runtimepath(buffer, FALSE, prt_resource_name,
5273- resource->filename)
5274- && resource->filename[0] != NUL);
5275-}
5276-
5277-/* PS CR and LF characters have platform independent values */
5278-#define PSLF (0x0a)
5279-#define PSCR (0x0d)
5280-
5281-/* Static buffer to read initial comments in a resource file, some can have a
5282- * couple of KB of comments! */
5283-#define PRT_FILE_BUFFER_LEN (2048)
5284-struct prt_resfile_buffer_S
5285-{
5286- char_u buffer[PRT_FILE_BUFFER_LEN];
5287- int len;
5288- int line_start;
5289- int line_end;
5290-};
5291-
5292-static struct prt_resfile_buffer_S prt_resfile;
5293-
5294- static int
5295-prt_resfile_next_line()
5296-{
5297- int index;
5298-
5299- /* Move to start of next line and then find end of line */
5300- index = prt_resfile.line_end + 1;
5301- while (index < prt_resfile.len)
5302- {
5303- if (prt_resfile.buffer[index] != PSLF && prt_resfile.buffer[index]
5304- != PSCR)
5305- break;
5306- index++;
5307- }
5308- prt_resfile.line_start = index;
5309-
5310- while (index < prt_resfile.len)
5311- {
5312- if (prt_resfile.buffer[index] == PSLF || prt_resfile.buffer[index]
5313- == PSCR)
5314- break;
5315- index++;
5316- }
5317- prt_resfile.line_end = index;
5318-
5319- return (index < prt_resfile.len);
5320-}
5321-
5322- static int
5323-prt_resfile_strncmp(offset, string, len)
5324- int offset;
5325- char *string;
5326- int len;
5327-{
5328- /* Force not equal if string is longer than remainder of line */
5329- if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset)))
5330- return 1;
5331-
5332- return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset],
5333- string, len);
5334-}
5335-
5336- static int
5337-prt_resfile_skip_nonws(offset)
5338- int offset;
5339-{
5340- int index;
5341-
5342- index = prt_resfile.line_start + offset;
5343- while (index < prt_resfile.line_end)
5344- {
5345- if (isspace(prt_resfile.buffer[index]))
5346- return index - prt_resfile.line_start;
5347- index++;
5348- }
5349- return -1;
5350-}
5351-
5352- static int
5353-prt_resfile_skip_ws(offset)
5354- int offset;
5355-{
5356- int index;
5357-
5358- index = prt_resfile.line_start + offset;
5359- while (index < prt_resfile.line_end)
5360- {
5361- if (!isspace(prt_resfile.buffer[index]))
5362- return index - prt_resfile.line_start;
5363- index++;
5364- }
5365- return -1;
5366-}
5367-
5368-/* prt_next_dsc() - returns detail on next DSC comment line found. Returns true
5369- * if a DSC comment is found, else false */
5370- static int
5371-prt_next_dsc(p_dsc_line)
5372- struct prt_dsc_line_S *p_dsc_line;
5373-{
5374- int comment;
5375- int offset;
5376-
5377- /* Move to start of next line */
5378- if (!prt_resfile_next_line())
5379- return FALSE;
5380-
5381- /* DSC comments always start %% */
5382- if (prt_resfile_strncmp(0, "%%", 2) != 0)
5383- return FALSE;
5384-
5385- /* Find type of DSC comment */
5386- for (comment = 0; comment < NUM_ELEMENTS(prt_dsc_table); comment++)
5387- if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,
5388- prt_dsc_table[comment].len) == 0)
5389- break;
5390-
5391- if (comment != NUM_ELEMENTS(prt_dsc_table))
5392- {
5393- /* Return type of comment */
5394- p_dsc_line->type = prt_dsc_table[comment].type;
5395- offset = prt_dsc_table[comment].len;
5396- }
5397- else
5398- {
5399- /* Unrecognised DSC comment, skip to ws after comment leader */
5400- p_dsc_line->type = PRT_DSC_MISC_TYPE;
5401- offset = prt_resfile_skip_nonws(0);
5402- if (offset == -1)
5403- return FALSE;
5404- }
5405-
5406- /* Skip ws to comment value */
5407- offset = prt_resfile_skip_ws(offset);
5408- if (offset == -1)
5409- return FALSE;
5410-
5411- p_dsc_line->string = &prt_resfile.buffer[prt_resfile.line_start + offset];
5412- p_dsc_line->len = prt_resfile.line_end - (prt_resfile.line_start + offset);
5413-
5414- return TRUE;
5415-}
5416-
5417-/* Improved hand crafted parser to get the type, title, and version number of a
5418- * PS resource file so the file details can be added to the DSC header comments.
5419- */
5420- static int
5421-prt_open_resource(resource)
5422- struct prt_ps_resource_S *resource;
5423-{
5424- int offset;
5425- int seen_all;
5426- int seen_title;
5427- int seen_version;
5428- FILE *fd_resource;
5429- struct prt_dsc_line_S dsc_line;
5430-
5431- fd_resource = mch_fopen((char *)resource->filename, READBIN);
5432- if (fd_resource == NULL)
5433- {
5434- EMSG2(_("E624: Can't open file \"%s\""), resource->filename);
5435- return FALSE;
5436- }
5437- vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN);
5438-
5439- /* Parse first line to ensure valid resource file */
5440- prt_resfile.len = fread((char *)prt_resfile.buffer, sizeof(char_u),
5441- PRT_FILE_BUFFER_LEN, fd_resource);
5442- if (ferror(fd_resource))
5443- {
5444- EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
5445- resource->filename);
5446- fclose(fd_resource);
5447- return FALSE;
5448- }
5449-
5450- prt_resfile.line_end = -1;
5451- prt_resfile.line_start = 0;
5452- if (!prt_resfile_next_line())
5453- return FALSE;
5454-
5455- offset = 0;
5456-
5457- if (prt_resfile_strncmp(offset, PRT_RESOURCE_HEADER,
5458- STRLEN(PRT_RESOURCE_HEADER)) != 0)
5459- {
5460- EMSG2(_("E618: file \"%s\" is not a PostScript resource file"),
5461- resource->filename);
5462- fclose(fd_resource);
5463- return FALSE;
5464- }
5465-
5466- /* Skip over any version numbers and following ws */
5467- offset += STRLEN(PRT_RESOURCE_HEADER);
5468- offset = prt_resfile_skip_nonws(offset);
5469- if (offset == -1)
5470- return FALSE;
5471- offset = prt_resfile_skip_ws(offset);
5472- if (offset == -1)
5473- return FALSE;
5474-
5475- if (prt_resfile_strncmp(offset, PRT_RESOURCE_RESOURCE,
5476- STRLEN(PRT_RESOURCE_RESOURCE)) != 0)
5477- {
5478- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
5479- resource->filename);
5480- fclose(fd_resource);
5481- return FALSE;
5482- }
5483- offset += STRLEN(PRT_RESOURCE_RESOURCE);
5484-
5485- /* Decide type of resource in the file */
5486- if (prt_resfile_strncmp(offset, PRT_RESOURCE_PROCSET,
5487- STRLEN(PRT_RESOURCE_PROCSET)) == 0)
5488- resource->type = PRT_RESOURCE_TYPE_PROCSET;
5489- else if (prt_resfile_strncmp(offset, PRT_RESOURCE_ENCODING,
5490- STRLEN(PRT_RESOURCE_ENCODING)) == 0)
5491- resource->type = PRT_RESOURCE_TYPE_ENCODING;
5492- else if (prt_resfile_strncmp(offset, PRT_RESOURCE_CMAP,
5493- STRLEN(PRT_RESOURCE_CMAP)) == 0)
5494- resource->type = PRT_RESOURCE_TYPE_CMAP;
5495- else
5496- {
5497- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
5498- resource->filename);
5499- fclose(fd_resource);
5500- return FALSE;
5501- }
5502-
5503- /* Look for title and version of resource */
5504- resource->title[0] = '\0';
5505- resource->version[0] = '\0';
5506- seen_title = FALSE;
5507- seen_version = FALSE;
5508- seen_all = FALSE;
5509- while (!seen_all && prt_next_dsc(&dsc_line))
5510- {
5511- switch (dsc_line.type)
5512- {
5513- case PRT_DSC_TITLE_TYPE:
5514- vim_strncpy(resource->title, dsc_line.string, dsc_line.len);
5515- seen_title = TRUE;
5516- if (seen_version)
5517- seen_all = TRUE;
5518- break;
5519-
5520- case PRT_DSC_VERSION_TYPE:
5521- vim_strncpy(resource->version, dsc_line.string, dsc_line.len);
5522- seen_version = TRUE;
5523- if (seen_title)
5524- seen_all = TRUE;
5525- break;
5526-
5527- case PRT_DSC_ENDCOMMENTS_TYPE:
5528- /* Wont find title or resource after this comment, stop searching */
5529- seen_all = TRUE;
5530- break;
5531-
5532- case PRT_DSC_MISC_TYPE:
5533- /* Not interested in whatever comment this line had */
5534- break;
5535- }
5536- }
5537-
5538- if (!seen_title || !seen_version)
5539- {
5540- EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"),
5541- resource->filename);
5542- fclose(fd_resource);
5543- return FALSE;
5544- }
5545-
5546- fclose(fd_resource);
5547-
5548- return TRUE;
5549-}
5550-
5551- static int
5552-prt_check_resource(resource, version)
5553- struct prt_ps_resource_S *resource;
5554- char_u *version;
5555-{
5556- /* Version number m.n should match, the revision number does not matter */
5557- if (STRNCMP(resource->version, version, STRLEN(version)))
5558- {
5559- EMSG2(_("E621: \"%s\" resource file has wrong version"),
5560- resource->name);
5561- return FALSE;
5562- }
5563-
5564- /* Other checks to be added as needed */
5565- return TRUE;
5566-}
5567-
5568- static void
5569-prt_dsc_start()
5570-{
5571- prt_write_string("%!PS-Adobe-3.0\n");
5572-}
5573-
5574- static void
5575-prt_dsc_noarg(comment)
5576- char *comment;
5577-{
5578- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5579- "%%%%%s\n", comment);
5580- prt_write_file(prt_line_buffer);
5581-}
5582-
5583- static void
5584-prt_dsc_textline(comment, text)
5585- char *comment;
5586- char *text;
5587-{
5588- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5589- "%%%%%s: %s\n", comment, text);
5590- prt_write_file(prt_line_buffer);
5591-}
5592-
5593- static void
5594-prt_dsc_text(comment, text)
5595- char *comment;
5596- char *text;
5597-{
5598- /* TODO - should scan 'text' for any chars needing escaping! */
5599- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5600- "%%%%%s: (%s)\n", comment, text);
5601- prt_write_file(prt_line_buffer);
5602-}
5603-
5604-#define prt_dsc_atend(c) prt_dsc_text((c), "atend")
5605-
5606- static void
5607-prt_dsc_ints(comment, count, ints)
5608- char *comment;
5609- int count;
5610- int *ints;
5611-{
5612- int i;
5613-
5614- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5615- "%%%%%s:", comment);
5616- prt_write_file(prt_line_buffer);
5617-
5618- for (i = 0; i < count; i++)
5619- {
5620- sprintf((char *)prt_line_buffer, " %d", ints[i]);
5621- prt_write_file(prt_line_buffer);
5622- }
5623-
5624- prt_write_string("\n");
5625-}
5626-
5627- static void
5628-prt_dsc_resources(comment, type, string)
5629- char *comment; /* if NULL add to previous */
5630- char *type;
5631- char *string;
5632-{
5633- if (comment != NULL)
5634- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5635- "%%%%%s: %s", comment, type);
5636- else
5637- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5638- "%%%%+ %s", type);
5639- prt_write_file(prt_line_buffer);
5640-
5641- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5642- " %s\n", string);
5643- prt_write_file(prt_line_buffer);
5644-}
5645-
5646- static void
5647-prt_dsc_font_resource(resource, ps_font)
5648- char *resource;
5649- struct prt_ps_font_S *ps_font;
5650-{
5651- int i;
5652-
5653- prt_dsc_resources(resource, "font",
5654- ps_font->ps_fontname[PRT_PS_FONT_ROMAN]);
5655- for (i = PRT_PS_FONT_BOLD ; i <= PRT_PS_FONT_BOLDOBLIQUE ; i++)
5656- if (ps_font->ps_fontname[i] != NULL)
5657- prt_dsc_resources(NULL, "font", ps_font->ps_fontname[i]);
5658-}
5659-
5660- static void
5661-prt_dsc_requirements(duplex, tumble, collate, color, num_copies)
5662- int duplex;
5663- int tumble;
5664- int collate;
5665- int color;
5666- int num_copies;
5667-{
5668- /* Only output the comment if we need to.
5669- * Note: tumble is ignored if we are not duplexing
5670- */
5671- if (!(duplex || collate || color || (num_copies > 1)))
5672- return;
5673-
5674- sprintf((char *)prt_line_buffer, "%%%%Requirements:");
5675- prt_write_file(prt_line_buffer);
5676-
5677- if (duplex)
5678- {
5679- prt_write_string(" duplex");
5680- if (tumble)
5681- prt_write_string("(tumble)");
5682- }
5683- if (collate)
5684- prt_write_string(" collate");
5685- if (color)
5686- prt_write_string(" color");
5687- if (num_copies > 1)
5688- {
5689- prt_write_string(" numcopies(");
5690- /* Note: no space wanted so dont use prt_write_int() */
5691- sprintf((char *)prt_line_buffer, "%d", num_copies);
5692- prt_write_file(prt_line_buffer);
5693- prt_write_string(")");
5694- }
5695- prt_write_string("\n");
5696-}
5697-
5698- static void
5699-prt_dsc_docmedia(paper_name, width, height, weight, colour, type)
5700- char *paper_name;
5701- double width;
5702- double height;
5703- double weight;
5704- char *colour;
5705- char *type;
5706-{
5707- vim_snprintf((char *)prt_line_buffer, sizeof(prt_line_buffer),
5708- "%%%%DocumentMedia: %s ", paper_name);
5709- prt_write_file(prt_line_buffer);
5710- prt_write_real(width, 2);
5711- prt_write_real(height, 2);
5712- prt_write_real(weight, 2);
5713- if (colour == NULL)
5714- prt_write_string("()");
5715- else
5716- prt_write_string(colour);
5717- prt_write_string(" ");
5718- if (type == NULL)
5719- prt_write_string("()");
5720- else
5721- prt_write_string(type);
5722- prt_write_string("\n");
5723-}
5724-
5725- void
5726-mch_print_cleanup()
5727-{
5728-#ifdef FEAT_MBYTE
5729- if (prt_out_mbyte)
5730- {
5731- int i;
5732-
5733- /* Free off all CID font names created, but first clear duplicate
5734- * pointers to the same string (when the same font is used for more than
5735- * one style).
5736- */
5737- for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++)
5738- {
5739- if (prt_ps_mb_font.ps_fontname[i] != NULL)
5740- vim_free(prt_ps_mb_font.ps_fontname[i]);
5741- prt_ps_mb_font.ps_fontname[i] = NULL;
5742- }
5743- }
5744-
5745- if (prt_do_conv)
5746- {
5747- convert_setup(&prt_conv, NULL, NULL);
5748- prt_do_conv = FALSE;
5749- }
5750-#endif
5751- if (prt_ps_fd != NULL)
5752- {
5753- fclose(prt_ps_fd);
5754- prt_ps_fd = NULL;
5755- prt_file_error = FALSE;
5756- }
5757- if (prt_ps_file_name != NULL)
5758- {
5759- vim_free(prt_ps_file_name);
5760- prt_ps_file_name = NULL;
5761- }
5762-}
5763-
5764- static float
5765-to_device_units(idx, physsize, def_number)
5766- int idx;
5767- double physsize;
5768- int def_number;
5769-{
5770- float ret;
5771- int u;
5772- int nr;
5773-
5774- u = prt_get_unit(idx);
5775- if (u == PRT_UNIT_NONE)
5776- {
5777- u = PRT_UNIT_PERC;
5778- nr = def_number;
5779- }
5780- else
5781- nr = printer_opts[idx].number;
5782-
5783- switch (u)
5784- {
5785- case PRT_UNIT_INCH:
5786- ret = (float)(nr * PRT_PS_DEFAULT_DPI);
5787- break;
5788- case PRT_UNIT_MM:
5789- ret = (float)(nr * PRT_PS_DEFAULT_DPI) / (float)25.4;
5790- break;
5791- case PRT_UNIT_POINT:
5792- ret = (float)nr;
5793- break;
5794- case PRT_UNIT_PERC:
5795- default:
5796- ret = (float)(physsize * nr) / 100;
5797- break;
5798- }
5799-
5800- return ret;
5801-}
5802-
5803-/*
5804- * Calculate margins for given width and height from printoptions settings.
5805- */
5806- static void
5807-prt_page_margins(width, height, left, right, top, bottom)
5808- double width;
5809- double height;
5810- double *left;
5811- double *right;
5812- double *top;
5813- double *bottom;
5814-{
5815- *left = to_device_units(OPT_PRINT_LEFT, width, 10);
5816- *right = width - to_device_units(OPT_PRINT_RIGHT, width, 5);
5817- *top = height - to_device_units(OPT_PRINT_TOP, height, 5);
5818- *bottom = to_device_units(OPT_PRINT_BOT, height, 5);
5819-}
5820-
5821- static void
5822-prt_font_metrics(font_scale)
5823- int font_scale;
5824-{
5825- prt_line_height = (float)font_scale;
5826- prt_char_width = (float)PRT_PS_FONT_TO_USER(font_scale, prt_ps_font->wx);
5827-}
5828-
5829-
5830- static int
5831-prt_get_cpl()
5832-{
5833- if (prt_use_number())
5834- {
5835- prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width;
5836-#ifdef FEAT_MBYTE
5837- /* If we are outputting multi-byte characters then line numbers will be
5838- * printed with half width characters
5839- */
5840- if (prt_out_mbyte)
5841- prt_number_width /= 2;
5842-#endif
5843- prt_left_margin += prt_number_width;
5844- }
5845- else
5846- prt_number_width = 0.0;
5847-
5848- return (int)((prt_right_margin - prt_left_margin) / prt_char_width);
5849-}
5850-
5851-#ifdef FEAT_MBYTE
5852- static int
5853-prt_build_cid_fontname(font, name, name_len)
5854- int font;
5855- char_u *name;
5856- int name_len;
5857-{
5858- char *fontname;
5859-
5860- fontname = (char *)alloc(name_len + 1);
5861- if (fontname == NULL)
5862- return FALSE;
5863- vim_strncpy((char_u *)fontname, name, name_len);
5864- prt_ps_mb_font.ps_fontname[font] = fontname;
5865-
5866- return TRUE;
5867-}
5868-#endif
5869-
5870-/*
5871- * Get number of lines of text that fit on a page (excluding the header).
5872- */
5873- static int
5874-prt_get_lpp()
5875-{
5876- int lpp;
5877-
5878- /*
5879- * Calculate offset to lower left corner of background rect based on actual
5880- * font height (based on its bounding box) and the line height, handling the
5881- * case where the font height can exceed the line height.
5882- */
5883- prt_bgcol_offset = (float)PRT_PS_FONT_TO_USER(prt_line_height,
5884- prt_ps_font->bbox_min_y);
5885- if ((prt_ps_font->bbox_max_y - prt_ps_font->bbox_min_y) < 1000.0)
5886- {
5887- prt_bgcol_offset -= (float)PRT_PS_FONT_TO_USER(prt_line_height,
5888- (1000.0 - (prt_ps_font->bbox_max_y -
5889- prt_ps_font->bbox_min_y)) / 2);
5890- }
5891-
5892- /* Get height for topmost line based on background rect offset. */
5893- prt_first_line_height = prt_line_height + prt_bgcol_offset;
5894-
5895- /* Calculate lpp */
5896- lpp = (int)((prt_top_margin - prt_bottom_margin) / prt_line_height);
5897-
5898- /* Adjust top margin if there is a header */
5899- prt_top_margin -= prt_line_height * prt_header_height();
5900-
5901- return lpp - prt_header_height();
5902-}
5903-
5904-#ifdef FEAT_MBYTE
5905- static int
5906-prt_match_encoding(p_encoding, p_cmap, pp_mbenc)
5907- char *p_encoding;
5908- struct prt_ps_mbfont_S *p_cmap;
5909- struct prt_ps_encoding_S **pp_mbenc;
5910-{
5911- int mbenc;
5912- int enc_len;
5913- struct prt_ps_encoding_S *p_mbenc;
5914-
5915- *pp_mbenc = NULL;
5916- /* Look for recognised encoding */
5917- enc_len = STRLEN(p_encoding);
5918- p_mbenc = p_cmap->encodings;
5919- for (mbenc = 0; mbenc < p_cmap->num_encodings; mbenc++)
5920- {
5921- if (STRNICMP(p_mbenc->encoding, p_encoding, enc_len) == 0)
5922- {
5923- *pp_mbenc = p_mbenc;
5924- return TRUE;
5925- }
5926- p_mbenc++;
5927- }
5928- return FALSE;
5929-}
5930-
5931- static int
5932-prt_match_charset(p_charset, p_cmap, pp_mbchar)
5933- char *p_charset;
5934- struct prt_ps_mbfont_S *p_cmap;
5935- struct prt_ps_charset_S **pp_mbchar;
5936-{
5937- int mbchar;
5938- int char_len;
5939- struct prt_ps_charset_S *p_mbchar;
5940-
5941- /* Look for recognised character set, using default if one is not given */
5942- if (*p_charset == NUL)
5943- p_charset = p_cmap->defcs;
5944- char_len = STRLEN(p_charset);
5945- p_mbchar = p_cmap->charsets;
5946- for (mbchar = 0; mbchar < p_cmap->num_charsets; mbchar++)
5947- {
5948- if (STRNICMP(p_mbchar->charset, p_charset, char_len) == 0)
5949- {
5950- *pp_mbchar = p_mbchar;
5951- return TRUE;
5952- }
5953- p_mbchar++;
5954- }
5955- return FALSE;
5956-}
5957-#endif
5958-
5959-/*ARGSUSED*/
5960- int
5961-mch_print_init(psettings, jobname, forceit)
5962- prt_settings_T *psettings;
5963- char_u *jobname;
5964- int forceit;
5965-{
5966- int i;
5967- char *paper_name;
5968- int paper_strlen;
5969- int fontsize;
5970- char_u *p;
5971- double left;
5972- double right;
5973- double top;
5974- double bottom;
5975-#ifdef FEAT_MBYTE
5976- int cmap;
5977- char_u *p_encoding;
5978- struct prt_ps_encoding_S *p_mbenc;
5979- struct prt_ps_encoding_S *p_mbenc_first;
5980- struct prt_ps_charset_S *p_mbchar;
5981-#endif
5982-
5983-#if 0
5984- /*
5985- * TODO:
5986- * If "forceit" is false: pop up a dialog to select:
5987- * - printer name
5988- * - copies
5989- * - collated/uncollated
5990- * - duplex off/long side/short side
5991- * - paper size
5992- * - portrait/landscape
5993- * - font size
5994- *
5995- * If "forceit" is true: use the default printer and settings
5996- */
5997- if (forceit)
5998- s_pd.Flags |= PD_RETURNDEFAULT;
5999-#endif
6000-
6001- /*
6002- * Set up font and encoding.
6003- */
6004-#ifdef FEAT_MBYTE
6005- p_encoding = enc_skip(p_penc);
6006- if (*p_encoding == NUL)
6007- p_encoding = enc_skip(p_enc);
6008-
6009- /* Look for recognised multi-byte coding, and if the charset is recognised.
6010- * This is to cope with the fact that various unicode encodings are
6011- * supported in more than one of CJK. */
6012- p_mbenc = NULL;
6013- p_mbenc_first = NULL;
6014- p_mbchar = NULL;
6015- for (cmap = 0; cmap < NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
6016- if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
6017- &p_mbenc))
6018- {
6019- if (p_mbenc_first == NULL)
6020- p_mbenc_first = p_mbenc;
6021- if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap],
6022- &p_mbchar))
6023- break;
6024- }
6025-
6026- /* Use first encoding matched if no charset matched */
6027- if (p_mbchar == NULL && p_mbenc_first != NULL)
6028- p_mbenc = p_mbenc_first;
6029-
6030- prt_out_mbyte = (p_mbenc != NULL);
6031- if (prt_out_mbyte)
6032- {
6033- /* Build CMap name - will be same for all multi-byte fonts used */
6034- prt_cmap[0] = NUL;
6035-
6036- prt_custom_cmap = prt_out_mbyte && p_mbchar == NULL;
6037-
6038- if (!prt_custom_cmap)
6039- {
6040- /* Check encoding and character set are compatible */
6041- if ((p_mbenc->needs_charset&p_mbchar->has_charset) == 0)
6042- {
6043- EMSG(_("E673: Incompatible multi-byte encoding and character set."));
6044- return FALSE;
6045- }
6046-
6047- /* Add charset name if not empty */
6048- if (p_mbchar->cmap_charset != NULL)
6049- {
6050- vim_strncpy((char_u *)prt_cmap,
6051- (char_u *)p_mbchar->cmap_charset, sizeof(prt_cmap) - 3);
6052- STRCAT(prt_cmap, "-");
6053- }
6054- }
6055- else
6056- {
6057- /* Add custom CMap character set name */
6058- if (*p_pmcs == NUL)
6059- {
6060- EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding."));
6061- return FALSE;
6062- }
6063- vim_strncpy((char_u *)prt_cmap, p_pmcs, sizeof(prt_cmap) - 3);
6064- STRCAT(prt_cmap, "-");
6065- }
6066-
6067- /* CMap name ends with (optional) encoding name and -H for horizontal */
6068- if (p_mbenc->cmap_encoding != NULL && STRLEN(prt_cmap)
6069- + STRLEN(p_mbenc->cmap_encoding) + 3 < sizeof(prt_cmap))
6070- {
6071- STRCAT(prt_cmap, p_mbenc->cmap_encoding);
6072- STRCAT(prt_cmap, "-");
6073- }
6074- STRCAT(prt_cmap, "H");
6075-
6076- if (!mbfont_opts[OPT_MBFONT_REGULAR].present)
6077- {
6078- EMSG(_("E675: No default font specified for multi-byte printing."));
6079- return FALSE;
6080- }
6081-
6082- /* Derive CID font names with fallbacks if not defined */
6083- if (!prt_build_cid_fontname(PRT_PS_FONT_ROMAN,
6084- mbfont_opts[OPT_MBFONT_REGULAR].string,
6085- mbfont_opts[OPT_MBFONT_REGULAR].strlen))
6086- return FALSE;
6087- if (mbfont_opts[OPT_MBFONT_BOLD].present)
6088- if (!prt_build_cid_fontname(PRT_PS_FONT_BOLD,
6089- mbfont_opts[OPT_MBFONT_BOLD].string,
6090- mbfont_opts[OPT_MBFONT_BOLD].strlen))
6091- return FALSE;
6092- if (mbfont_opts[OPT_MBFONT_OBLIQUE].present)
6093- if (!prt_build_cid_fontname(PRT_PS_FONT_OBLIQUE,
6094- mbfont_opts[OPT_MBFONT_OBLIQUE].string,
6095- mbfont_opts[OPT_MBFONT_OBLIQUE].strlen))
6096- return FALSE;
6097- if (mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].present)
6098- if (!prt_build_cid_fontname(PRT_PS_FONT_BOLDOBLIQUE,
6099- mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string,
6100- mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen))
6101- return FALSE;
6102-
6103- /* Check if need to use Courier for ASCII code range, and if so pick up
6104- * the encoding to use */
6105- prt_use_courier = mbfont_opts[OPT_MBFONT_USECOURIER].present &&
6106- (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y');
6107- if (prt_use_courier)
6108- {
6109- /* Use national ASCII variant unless ASCII wanted */
6110- if (mbfont_opts[OPT_MBFONT_ASCII].present &&
6111- (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_ASCII].string[0]) == 'y'))
6112- prt_ascii_encoding = "ascii";
6113- else
6114- prt_ascii_encoding = prt_ps_mbfonts[cmap].ascii_enc;
6115- }
6116-
6117- prt_ps_font = &prt_ps_mb_font;
6118- }
6119- else
6120-#endif
6121- {
6122-#ifdef FEAT_MBYTE
6123- prt_use_courier = FALSE;
6124-#endif
6125- prt_ps_font = &prt_ps_courier_font;
6126- }
6127-
6128- /*
6129- * Find the size of the paper and set the margins.
6130- */
6131- prt_portrait = (!printer_opts[OPT_PRINT_PORTRAIT].present
6132- || TOLOWER_ASC(printer_opts[OPT_PRINT_PORTRAIT].string[0]) == 'y');
6133- if (printer_opts[OPT_PRINT_PAPER].present)
6134- {
6135- paper_name = (char *)printer_opts[OPT_PRINT_PAPER].string;
6136- paper_strlen = printer_opts[OPT_PRINT_PAPER].strlen;
6137- }
6138- else
6139- {
6140- paper_name = "A4";
6141- paper_strlen = 2;
6142- }
6143- for (i = 0; i < PRT_MEDIASIZE_LEN; ++i)
6144- if (STRLEN(prt_mediasize[i].name) == (unsigned)paper_strlen
6145- && STRNICMP(prt_mediasize[i].name, paper_name,
6146- paper_strlen) == 0)
6147- break;
6148- if (i == PRT_MEDIASIZE_LEN)
6149- i = 0;
6150- prt_media = i;
6151-
6152- /*
6153- * Set PS pagesize based on media dimensions and print orientation.
6154- * Note: Media and page sizes have defined meanings in PostScript and should
6155- * be kept distinct. Media is the paper (or transparency, or ...) that is
6156- * printed on, whereas the page size is the area that the PostScript
6157- * interpreter renders into.
6158- */
6159- if (prt_portrait)
6160- {
6161- prt_page_width = prt_mediasize[i].width;
6162- prt_page_height = prt_mediasize[i].height;
6163- }
6164- else
6165- {
6166- prt_page_width = prt_mediasize[i].height;
6167- prt_page_height = prt_mediasize[i].width;
6168- }
6169-
6170- /*
6171- * Set PS page margins based on the PS pagesize, not the mediasize - this
6172- * needs to be done before the cpl and lpp are calculated.
6173- */
6174- prt_page_margins(prt_page_width, prt_page_height, &left, &right, &top,
6175- &bottom);
6176- prt_left_margin = (float)left;
6177- prt_right_margin = (float)right;
6178- prt_top_margin = (float)top;
6179- prt_bottom_margin = (float)bottom;
6180-
6181- /*
6182- * Set up the font size.
6183- */
6184- fontsize = PRT_PS_DEFAULT_FONTSIZE;
6185- for (p = p_pfn; (p = vim_strchr(p, ':')) != NULL; ++p)
6186- if (p[1] == 'h' && VIM_ISDIGIT(p[2]))
6187- fontsize = atoi((char *)p + 2);
6188- prt_font_metrics(fontsize);
6189-
6190- /*
6191- * Return the number of characters per line, and lines per page for the
6192- * generic print code.
6193- */
6194- psettings->chars_per_line = prt_get_cpl();
6195- psettings->lines_per_page = prt_get_lpp();
6196-
6197- /* Catch margin settings that leave no space for output! */
6198- if (psettings->chars_per_line <= 0 || psettings->lines_per_page <= 0)
6199- return FAIL;
6200-
6201- /*
6202- * Sort out the number of copies to be printed. PS by default will do
6203- * uncollated copies for you, so once we know how many uncollated copies are
6204- * wanted cache it away and lie to the generic code that we only want one
6205- * uncollated copy.
6206- */
6207- psettings->n_collated_copies = 1;
6208- psettings->n_uncollated_copies = 1;
6209- prt_num_copies = 1;
6210- prt_collate = (!printer_opts[OPT_PRINT_COLLATE].present
6211- || TOLOWER_ASC(printer_opts[OPT_PRINT_COLLATE].string[0]) == 'y');
6212- if (prt_collate)
6213- {
6214- /* TODO: Get number of collated copies wanted. */
6215- psettings->n_collated_copies = 1;
6216- }
6217- else
6218- {
6219- /* TODO: Get number of uncollated copies wanted and update the cached
6220- * count.
6221- */
6222- prt_num_copies = 1;
6223- }
6224-
6225- psettings->jobname = jobname;
6226-
6227- /*
6228- * Set up printer duplex and tumble based on Duplex option setting - default
6229- * is long sided duplex printing (i.e. no tumble).
6230- */
6231- prt_duplex = TRUE;
6232- prt_tumble = FALSE;
6233- psettings->duplex = 1;
6234- if (printer_opts[OPT_PRINT_DUPLEX].present)
6235- {
6236- if (STRNICMP(printer_opts[OPT_PRINT_DUPLEX].string, "off", 3) == 0)
6237- {
6238- prt_duplex = FALSE;
6239- psettings->duplex = 0;
6240- }
6241- else if (STRNICMP(printer_opts[OPT_PRINT_DUPLEX].string, "short", 5)
6242- == 0)
6243- prt_tumble = TRUE;
6244- }
6245-
6246- /* For now user abort not supported */
6247- psettings->user_abort = 0;
6248-
6249- /* If the user didn't specify a file name, use a temp file. */
6250- if (psettings->outfile == NULL)
6251- {
6252- prt_ps_file_name = vim_tempname('p');
6253- if (prt_ps_file_name == NULL)
6254- {
6255- EMSG(_(e_notmp));
6256- return FAIL;
6257- }
6258- prt_ps_fd = mch_fopen((char *)prt_ps_file_name, WRITEBIN);
6259- }
6260- else
6261- {
6262- p = expand_env_save(psettings->outfile);
6263- if (p != NULL)
6264- {
6265- prt_ps_fd = mch_fopen((char *)p, WRITEBIN);
6266- vim_free(p);
6267- }
6268- }
6269- if (prt_ps_fd == NULL)
6270- {
6271- EMSG(_("E324: Can't open PostScript output file"));
6272- mch_print_cleanup();
6273- return FAIL;
6274- }
6275-
6276- prt_bufsiz = psettings->chars_per_line;
6277-#ifdef FEAT_MBYTE
6278- if (prt_out_mbyte)
6279- prt_bufsiz *= 2;
6280-#endif
6281- ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz);
6282-
6283- prt_page_num = 0;
6284-
6285- prt_attribute_change = FALSE;
6286- prt_need_moveto = FALSE;
6287- prt_need_font = FALSE;
6288- prt_need_fgcol = FALSE;
6289- prt_need_bgcol = FALSE;
6290- prt_need_underline = FALSE;
6291-
6292- prt_file_error = FALSE;
6293-
6294- return OK;
6295-}
6296-
6297- static int
6298-prt_add_resource(resource)
6299- struct prt_ps_resource_S *resource;
6300-{
6301- FILE* fd_resource;
6302- char_u resource_buffer[512];
6303- size_t bytes_read;
6304-
6305- fd_resource = mch_fopen((char *)resource->filename, READBIN);
6306- if (fd_resource == NULL)
6307- {
6308- EMSG2(_("E456: Can't open file \"%s\""), resource->filename);
6309- return FALSE;
6310- }
6311- prt_dsc_resources("BeginResource", prt_resource_types[resource->type],
6312- (char *)resource->title);
6313-
6314- prt_dsc_textline("BeginDocument", (char *)resource->filename);
6315-
6316- for (;;)
6317- {
6318- bytes_read = fread((char *)resource_buffer, sizeof(char_u),
6319- sizeof(resource_buffer), fd_resource);
6320- if (ferror(fd_resource))
6321- {
6322- EMSG2(_("E457: Can't read PostScript resource file \"%s\""),
6323- resource->filename);
6324- fclose(fd_resource);
6325- return FALSE;
6326- }
6327- if (bytes_read == 0)
6328- break;
6329- prt_write_file_raw_len(resource_buffer, bytes_read);
6330- if (prt_file_error)
6331- {
6332- fclose(fd_resource);
6333- return FALSE;
6334- }
6335- }
6336- fclose(fd_resource);
6337-
6338- prt_dsc_noarg("EndDocument");
6339-
6340- prt_dsc_noarg("EndResource");
6341-
6342- return TRUE;
6343-}
6344-
6345- int
6346-mch_print_begin(psettings)
6347- prt_settings_T *psettings;
6348-{
6349- time_t now;
6350- int bbox[4];
6351- char *p_time;
6352- double left;
6353- double right;
6354- double top;
6355- double bottom;
6356- struct prt_ps_resource_S res_prolog;
6357- struct prt_ps_resource_S res_encoding;
6358- char buffer[256];
6359- char_u *p_encoding;
6360-#ifdef FEAT_MBYTE
6361- struct prt_ps_resource_S res_cidfont;
6362- struct prt_ps_resource_S res_cmap;
6363-#endif
6364-
6365- /*
6366- * PS DSC Header comments - no PS code!
6367- */
6368- prt_dsc_start();
6369- prt_dsc_textline("Title", (char *)psettings->jobname);
6370- if (!get_user_name((char_u *)buffer, 256))
6371- STRCPY(buffer, "Unknown");
6372- prt_dsc_textline("For", buffer);
6373- prt_dsc_textline("Creator", VIM_VERSION_LONG);
6374- /* Note: to ensure Clean8bit I don't think we can use LC_TIME */
6375- now = time(NULL);
6376- p_time = ctime(&now);
6377- /* Note: ctime() adds a \n so we have to remove it :-( */
6378- *(vim_strchr((char_u *)p_time, '\n')) = '\0';
6379- prt_dsc_textline("CreationDate", p_time);
6380- prt_dsc_textline("DocumentData", "Clean8Bit");
6381- prt_dsc_textline("Orientation", "Portrait");
6382- prt_dsc_atend("Pages");
6383- prt_dsc_textline("PageOrder", "Ascend");
6384- /* The bbox does not change with orientation - it is always in the default
6385- * user coordinate system! We have to recalculate right and bottom
6386- * coordinates based on the font metrics for the bbox to be accurate. */
6387- prt_page_margins(prt_mediasize[prt_media].width,
6388- prt_mediasize[prt_media].height,
6389- &left, &right, &top, &bottom);
6390- bbox[0] = (int)left;
6391- if (prt_portrait)
6392- {
6393- /* In portrait printing the fixed point is the top left corner so we
6394- * derive the bbox from that point. We have the expected cpl chars
6395- * across the media and lpp lines down the media.
6396- */
6397- bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height())
6398- * prt_line_height);
6399- bbox[2] = (int)(left + psettings->chars_per_line * prt_char_width
6400- + 0.5);
6401- bbox[3] = (int)(top + 0.5);
6402- }
6403- else
6404- {
6405- /* In landscape printing the fixed point is the bottom left corner so we
6406- * derive the bbox from that point. We have lpp chars across the media
6407- * and cpl lines up the media.
6408- */
6409- bbox[1] = (int)bottom;
6410- bbox[2] = (int)(left + ((psettings->lines_per_page
6411- + prt_header_height()) * prt_line_height) + 0.5);
6412- bbox[3] = (int)(bottom + psettings->chars_per_line * prt_char_width
6413- + 0.5);
6414- }
6415- prt_dsc_ints("BoundingBox", 4, bbox);
6416- /* The media width and height does not change with landscape printing! */
6417- prt_dsc_docmedia(prt_mediasize[prt_media].name,
6418- prt_mediasize[prt_media].width,
6419- prt_mediasize[prt_media].height,
6420- (double)0, NULL, NULL);
6421- /* Define fonts needed */
6422-#ifdef FEAT_MBYTE
6423- if (!prt_out_mbyte || prt_use_courier)
6424-#endif
6425- prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font);
6426-#ifdef FEAT_MBYTE
6427- if (prt_out_mbyte)
6428- {
6429- prt_dsc_font_resource((prt_use_courier ? NULL
6430- : "DocumentNeededResources"), &prt_ps_mb_font);
6431- if (!prt_custom_cmap)
6432- prt_dsc_resources(NULL, "cmap", prt_cmap);
6433- }
6434-#endif
6435-
6436- /* Search for external resources VIM supplies */
6437- if (!prt_find_resource("prolog", &res_prolog))
6438- {
6439- EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\""));
6440- return FALSE;
6441- }
6442- if (!prt_open_resource(&res_prolog))
6443- return FALSE;
6444- if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION))
6445- return FALSE;
6446-#ifdef FEAT_MBYTE
6447- if (prt_out_mbyte)
6448- {
6449- /* Look for required version of multi-byte printing procset */
6450- if (!prt_find_resource("cidfont", &res_cidfont))
6451- {
6452- EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\""));
6453- return FALSE;
6454- }
6455- if (!prt_open_resource(&res_cidfont))
6456- return FALSE;
6457- if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION))
6458- return FALSE;
6459- }
6460-#endif
6461-
6462- /* Find an encoding to use for printing.
6463- * Check 'printencoding'. If not set or not found, then use 'encoding'. If
6464- * that cannot be found then default to "latin1".
6465- * Note: VIM specific encoding header is always skipped.
6466- */
6467-#ifdef FEAT_MBYTE
6468- if (!prt_out_mbyte)
6469- {
6470-#endif
6471- p_encoding = enc_skip(p_penc);
6472- if (*p_encoding == NUL
6473- || !prt_find_resource((char *)p_encoding, &res_encoding))
6474- {
6475- /* 'printencoding' not set or not supported - find alternate */
6476-#ifdef FEAT_MBYTE
6477- int props;
6478-
6479- p_encoding = enc_skip(p_enc);
6480- props = enc_canon_props(p_encoding);
6481- if (!(props & ENC_8BIT)
6482- || !prt_find_resource((char *)p_encoding, &res_encoding))
6483- /* 8-bit 'encoding' is not supported */
6484-#endif
6485- {
6486- /* Use latin1 as default printing encoding */
6487- p_encoding = (char_u *)"latin1";
6488- if (!prt_find_resource((char *)p_encoding, &res_encoding))
6489- {
6490- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
6491- p_encoding);
6492- return FALSE;
6493- }
6494- }
6495- }
6496- if (!prt_open_resource(&res_encoding))
6497- return FALSE;
6498- /* For the moment there are no checks on encoding resource files to
6499- * perform */
6500-#ifdef FEAT_MBYTE
6501- }
6502- else
6503- {
6504- p_encoding = enc_skip(p_penc);
6505- if (*p_encoding == NUL)
6506- p_encoding = enc_skip(p_enc);
6507- if (prt_use_courier)
6508- {
6509- /* Include ASCII range encoding vector */
6510- if (!prt_find_resource(prt_ascii_encoding, &res_encoding))
6511- {
6512- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
6513- prt_ascii_encoding);
6514- return FALSE;
6515- }
6516- if (!prt_open_resource(&res_encoding))
6517- return FALSE;
6518- /* For the moment there are no checks on encoding resource files to
6519- * perform */
6520- }
6521- }
6522-
6523- prt_conv.vc_type = CONV_NONE;
6524- if (!(enc_canon_props(p_enc) & enc_canon_props(p_encoding) & ENC_8BIT)) {
6525- /* Set up encoding conversion if required */
6526- if (FAIL == convert_setup(&prt_conv, p_enc, p_encoding))
6527- {
6528- EMSG2(_("E620: Unable to convert to print encoding \"%s\""),
6529- p_encoding);
6530- return FALSE;
6531- }
6532- prt_do_conv = TRUE;
6533- }
6534- prt_do_conv = prt_conv.vc_type != CONV_NONE;
6535-
6536- if (prt_out_mbyte && prt_custom_cmap)
6537- {
6538- /* Find user supplied CMap */
6539- if (!prt_find_resource(prt_cmap, &res_cmap))
6540- {
6541- EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
6542- prt_cmap);
6543- return FALSE;
6544- }
6545- if (!prt_open_resource(&res_cmap))
6546- return FALSE;
6547- }
6548-#endif
6549-
6550- /* List resources supplied */
6551- STRCPY(buffer, res_prolog.title);
6552- STRCAT(buffer, " ");
6553- STRCAT(buffer, res_prolog.version);
6554- prt_dsc_resources("DocumentSuppliedResources", "procset", buffer);
6555-#ifdef FEAT_MBYTE
6556- if (prt_out_mbyte)
6557- {
6558- STRCPY(buffer, res_cidfont.title);
6559- STRCAT(buffer, " ");
6560- STRCAT(buffer, res_cidfont.version);
6561- prt_dsc_resources(NULL, "procset", buffer);
6562-
6563- if (prt_custom_cmap)
6564- {
6565- STRCPY(buffer, res_cmap.title);
6566- STRCAT(buffer, " ");
6567- STRCAT(buffer, res_cmap.version);
6568- prt_dsc_resources(NULL, "cmap", buffer);
6569- }
6570- }
6571- if (!prt_out_mbyte || prt_use_courier)
6572-#endif
6573- {
6574- STRCPY(buffer, res_encoding.title);
6575- STRCAT(buffer, " ");
6576- STRCAT(buffer, res_encoding.version);
6577- prt_dsc_resources(NULL, "encoding", buffer);
6578- }
6579- prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate,
6580-#ifdef FEAT_SYN_HL
6581- psettings->do_syntax
6582-#else
6583- 0
6584-#endif
6585- , prt_num_copies);
6586- prt_dsc_noarg("EndComments");
6587-
6588- /*
6589- * PS Document page defaults
6590- */
6591- prt_dsc_noarg("BeginDefaults");
6592-
6593- /* List font resources most likely common to all pages */
6594-#ifdef FEAT_MBYTE
6595- if (!prt_out_mbyte || prt_use_courier)
6596-#endif
6597- prt_dsc_font_resource("PageResources", &prt_ps_courier_font);
6598-#ifdef FEAT_MBYTE
6599- if (prt_out_mbyte)
6600- {
6601- prt_dsc_font_resource((prt_use_courier ? NULL : "PageResources"),
6602- &prt_ps_mb_font);
6603- if (!prt_custom_cmap)
6604- prt_dsc_resources(NULL, "cmap", prt_cmap);
6605- }
6606-#endif
6607-
6608- /* Paper will be used for all pages */
6609- prt_dsc_textline("PageMedia", prt_mediasize[prt_media].name);
6610-
6611- prt_dsc_noarg("EndDefaults");
6612-
6613- /*
6614- * PS Document prolog inclusion - all required procsets.
6615- */
6616- prt_dsc_noarg("BeginProlog");
6617-
6618- /* Add required procsets - NOTE: order is important! */
6619- if (!prt_add_resource(&res_prolog))
6620- return FALSE;
6621-#ifdef FEAT_MBYTE
6622- if (prt_out_mbyte)
6623- {
6624- /* Add CID font procset, and any user supplied CMap */
6625- if (!prt_add_resource(&res_cidfont))
6626- return FALSE;
6627- if (prt_custom_cmap && !prt_add_resource(&res_cmap))
6628- return FALSE;
6629- }
6630-#endif
6631-
6632-#ifdef FEAT_MBYTE
6633- if (!prt_out_mbyte || prt_use_courier)
6634-#endif
6635- /* There will be only one Roman font encoding to be included in the PS
6636- * file. */
6637- if (!prt_add_resource(&res_encoding))
6638- return FALSE;
6639-
6640- prt_dsc_noarg("EndProlog");
6641-
6642- /*
6643- * PS Document setup - must appear after the prolog
6644- */
6645- prt_dsc_noarg("BeginSetup");
6646-
6647- /* Device setup - page size and number of uncollated copies */
6648- prt_write_int((int)prt_mediasize[prt_media].width);
6649- prt_write_int((int)prt_mediasize[prt_media].height);
6650- prt_write_int(0);
6651- prt_write_string("sps\n");
6652- prt_write_int(prt_num_copies);
6653- prt_write_string("nc\n");
6654- prt_write_boolean(prt_duplex);
6655- prt_write_boolean(prt_tumble);
6656- prt_write_string("dt\n");
6657- prt_write_boolean(prt_collate);
6658- prt_write_string("c\n");
6659-
6660- /* Font resource inclusion and definition */
6661-#ifdef FEAT_MBYTE
6662- if (!prt_out_mbyte || prt_use_courier)
6663- {
6664- /* When using Courier for ASCII range when printing multi-byte, need to
6665- * pick up ASCII encoding to use with it. */
6666- if (prt_use_courier)
6667- p_encoding = (char_u *)prt_ascii_encoding;
6668-#endif
6669- prt_dsc_resources("IncludeResource", "font",
6670- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
6671- prt_def_font("F0", (char *)p_encoding, (int)prt_line_height,
6672- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
6673- prt_dsc_resources("IncludeResource", "font",
6674- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
6675- prt_def_font("F1", (char *)p_encoding, (int)prt_line_height,
6676- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]);
6677- prt_dsc_resources("IncludeResource", "font",
6678- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
6679- prt_def_font("F2", (char *)p_encoding, (int)prt_line_height,
6680- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
6681- prt_dsc_resources("IncludeResource", "font",
6682- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
6683- prt_def_font("F3", (char *)p_encoding, (int)prt_line_height,
6684- prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
6685-#ifdef FEAT_MBYTE
6686- }
6687- if (prt_out_mbyte)
6688- {
6689- /* Define the CID fonts to be used in the job. Typically CJKV fonts do
6690- * not have an italic form being a western style, so where no font is
6691- * defined for these faces VIM falls back to an existing face.
6692- * Note: if using Courier for the ASCII range then the printout will
6693- * have bold/italic/bolditalic regardless of the setting of printmbfont.
6694- */
6695- prt_dsc_resources("IncludeResource", "font",
6696- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
6697- if (!prt_custom_cmap)
6698- prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
6699- prt_def_cidfont("CF0", (int)prt_line_height,
6700- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]);
6701-
6702- if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD] != NULL)
6703- {
6704- prt_dsc_resources("IncludeResource", "font",
6705- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
6706- if (!prt_custom_cmap)
6707- prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
6708- prt_def_cidfont("CF1", (int)prt_line_height,
6709- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]);
6710- }
6711- else
6712- /* Use ROMAN for BOLD */
6713- prt_dup_cidfont("CF0", "CF1");
6714-
6715- if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE] != NULL)
6716- {
6717- prt_dsc_resources("IncludeResource", "font",
6718- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
6719- if (!prt_custom_cmap)
6720- prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
6721- prt_def_cidfont("CF2", (int)prt_line_height,
6722- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]);
6723- }
6724- else
6725- /* Use ROMAN for OBLIQUE */
6726- prt_dup_cidfont("CF0", "CF2");
6727-
6728- if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE] != NULL)
6729- {
6730- prt_dsc_resources("IncludeResource", "font",
6731- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
6732- if (!prt_custom_cmap)
6733- prt_dsc_resources("IncludeResource", "cmap", prt_cmap);
6734- prt_def_cidfont("CF3", (int)prt_line_height,
6735- prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]);
6736- }
6737- else
6738- /* Use BOLD for BOLDOBLIQUE */
6739- prt_dup_cidfont("CF1", "CF3");
6740- }
6741-#endif
6742-
6743- /* Misc constant vars used for underlining and background rects */
6744- prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height,
6745- prt_ps_font->uline_offset), 2);
6746- prt_def_var("UW", PRT_PS_FONT_TO_USER(prt_line_height,
6747- prt_ps_font->uline_width), 2);
6748- prt_def_var("BO", prt_bgcol_offset, 2);
6749-
6750- prt_dsc_noarg("EndSetup");
6751-
6752- /* Fail if any problems writing out to the PS file */
6753- return !prt_file_error;
6754-}
6755-
6756- void
6757-mch_print_end(psettings)
6758- prt_settings_T *psettings;
6759-{
6760- prt_dsc_noarg("Trailer");
6761-
6762- /*
6763- * Output any info we don't know in toto until we finish
6764- */
6765- prt_dsc_ints("Pages", 1, &prt_page_num);
6766-
6767- prt_dsc_noarg("EOF");
6768-
6769- /* Write CTRL-D to close serial communication link if used.
6770- * NOTHING MUST BE WRITTEN AFTER THIS! */
6771- prt_write_file((char_u *)IF_EB("\004", "\067"));
6772-
6773- if (!prt_file_error && psettings->outfile == NULL
6774- && !got_int && !psettings->user_abort)
6775- {
6776- /* Close the file first. */
6777- if (prt_ps_fd != NULL)
6778- {
6779- fclose(prt_ps_fd);
6780- prt_ps_fd = NULL;
6781- }
6782- prt_message((char_u *)_("Sending to printer..."));
6783-
6784- /* Not printing to a file: use 'printexpr' to print the file. */
6785- if (eval_printexpr(prt_ps_file_name, psettings->arguments) == FAIL)
6786- EMSG(_("E365: Failed to print PostScript file"));
6787- else
6788- prt_message((char_u *)_("Print job sent."));
6789- }
6790-
6791- mch_print_cleanup();
6792-}
6793-
6794- int
6795-mch_print_end_page()
6796-{
6797- prt_flush_buffer();
6798-
6799- prt_write_string("re sp\n");
6800-
6801- prt_dsc_noarg("PageTrailer");
6802-
6803- return !prt_file_error;
6804-}
6805-
6806-/*ARGSUSED*/
6807- int
6808-mch_print_begin_page(str)
6809- char_u *str;
6810-{
6811- int page_num[2];
6812-
6813- prt_page_num++;
6814-
6815- page_num[0] = page_num[1] = prt_page_num;
6816- prt_dsc_ints("Page", 2, page_num);
6817-
6818- prt_dsc_noarg("BeginPageSetup");
6819-
6820- prt_write_string("sv\n0 g\n");
6821-#ifdef FEAT_MBYTE
6822- prt_in_ascii = !prt_out_mbyte;
6823- if (prt_out_mbyte)
6824- prt_write_string("CF0 sf\n");
6825- else
6826-#endif
6827- prt_write_string("F0 sf\n");
6828- prt_fgcol = PRCOLOR_BLACK;
6829- prt_bgcol = PRCOLOR_WHITE;
6830- prt_font = PRT_PS_FONT_ROMAN;
6831-
6832- /* Set up page transformation for landscape printing. */
6833- if (!prt_portrait)
6834- {
6835- prt_write_int(-((int)prt_mediasize[prt_media].width));
6836- prt_write_string("sl\n");
6837- }
6838-
6839- prt_dsc_noarg("EndPageSetup");
6840-
6841- /* We have reset the font attributes, force setting them again. */
6842- curr_bg = (long_u)0xffffffff;
6843- curr_fg = (long_u)0xffffffff;
6844- curr_bold = MAYBE;
6845-
6846- return !prt_file_error;
6847-}
6848-
6849- int
6850-mch_print_blank_page()
6851-{
6852- return (mch_print_begin_page(NULL) ? (mch_print_end_page()) : FALSE);
6853-}
6854-
6855-static float prt_pos_x = 0;
6856-static float prt_pos_y = 0;
6857-
6858- void
6859-mch_print_start_line(margin, page_line)
6860- int margin;
6861- int page_line;
6862-{
6863- prt_pos_x = prt_left_margin;
6864- if (margin)
6865- prt_pos_x -= prt_number_width;
6866-
6867- prt_pos_y = prt_top_margin - prt_first_line_height -
6868- page_line * prt_line_height;
6869-
6870- prt_attribute_change = TRUE;
6871- prt_need_moveto = TRUE;
6872-#ifdef FEAT_MBYTE
6873- prt_half_width = FALSE;
6874-#endif
6875-}
6876-
6877-/*ARGSUSED*/
6878- int
6879-mch_print_text_out(p, len)
6880- char_u *p;
6881- int len;
6882-{
6883- int need_break;
6884- char_u ch;
6885- char_u ch_buff[8];
6886- float char_width;
6887- float next_pos;
6888-#ifdef FEAT_MBYTE
6889- int in_ascii;
6890- int half_width;
6891-#endif
6892-
6893- char_width = prt_char_width;
6894-
6895-#ifdef FEAT_MBYTE
6896- /* Ideally VIM would create a rearranged CID font to combine a Roman and
6897- * CJKV font to do what VIM is doing here - use a Roman font for characters
6898- * in the ASCII range, and the origingal CID font for everything else.
6899- * The problem is that GhostScript still (as of 8.13) does not support
6900- * rearranged fonts even though they have been documented by Adobe for 7
6901- * years! If they ever do, a lot of this code will disappear.
6902- */
6903- if (prt_use_courier)
6904- {
6905- in_ascii = (len == 1 && *p < 0x80);
6906- if (prt_in_ascii)
6907- {
6908- if (!in_ascii)
6909- {
6910- /* No longer in ASCII range - need to switch font */
6911- prt_in_ascii = FALSE;
6912- prt_need_font = TRUE;
6913- prt_attribute_change = TRUE;
6914- }
6915- }
6916- else if (in_ascii)
6917- {
6918- /* Now in ASCII range - need to switch font */
6919- prt_in_ascii = TRUE;
6920- prt_need_font = TRUE;
6921- prt_attribute_change = TRUE;
6922- }
6923- }
6924- if (prt_out_mbyte)
6925- {
6926- half_width = ((*mb_ptr2cells)(p) == 1);
6927- if (half_width)
6928- char_width /= 2;
6929- if (prt_half_width)
6930- {
6931- if (!half_width)
6932- {
6933- prt_half_width = FALSE;
6934- prt_pos_x += prt_char_width/4;
6935- prt_need_moveto = TRUE;
6936- prt_attribute_change = TRUE;
6937- }
6938- }
6939- else if (half_width)
6940- {
6941- prt_half_width = TRUE;
6942- prt_pos_x += prt_char_width/4;
6943- prt_need_moveto = TRUE;
6944- prt_attribute_change = TRUE;
6945- }
6946- }
6947-#endif
6948-
6949- /* Output any required changes to the graphics state, after flushing any
6950- * text buffered so far.
6951- */
6952- if (prt_attribute_change)
6953- {
6954- prt_flush_buffer();
6955- /* Reset count of number of chars that will be printed */
6956- prt_text_run = 0;
6957-
6958- if (prt_need_moveto)
6959- {
6960- prt_pos_x_moveto = prt_pos_x;
6961- prt_pos_y_moveto = prt_pos_y;
6962- prt_do_moveto = TRUE;
6963-
6964- prt_need_moveto = FALSE;
6965- }
6966- if (prt_need_font)
6967- {
6968-#ifdef FEAT_MBYTE
6969- if (!prt_in_ascii)
6970- prt_write_string("CF");
6971- else
6972-#endif
6973- prt_write_string("F");
6974- prt_write_int(prt_font);
6975- prt_write_string("sf\n");
6976- prt_need_font = FALSE;
6977- }
6978- if (prt_need_fgcol)
6979- {
6980- int r, g, b;
6981- r = ((unsigned)prt_fgcol & 0xff0000) >> 16;
6982- g = ((unsigned)prt_fgcol & 0xff00) >> 8;
6983- b = prt_fgcol & 0xff;
6984-
6985- prt_write_real(r / 255.0, 3);
6986- if (r == g && g == b)
6987- prt_write_string("g\n");
6988- else
6989- {
6990- prt_write_real(g / 255.0, 3);
6991- prt_write_real(b / 255.0, 3);
6992- prt_write_string("r\n");
6993- }
6994- prt_need_fgcol = FALSE;
6995- }
6996-
6997- if (prt_bgcol != PRCOLOR_WHITE)
6998- {
6999- prt_new_bgcol = prt_bgcol;
7000- if (prt_need_bgcol)
7001- prt_do_bgcol = TRUE;
7002- }
7003- else
7004- prt_do_bgcol = FALSE;
7005- prt_need_bgcol = FALSE;
7006-
7007- if (prt_need_underline)
7008- prt_do_underline = prt_underline;
7009- prt_need_underline = FALSE;
7010-
7011- prt_attribute_change = FALSE;
7012- }
7013-
7014-#ifdef FEAT_MBYTE
7015- if (prt_do_conv)
7016- {
7017- /* Convert from multi-byte to 8-bit encoding */
7018- p = string_convert(&prt_conv, p, &len);
7019- if (p == NULL)
7020- p = (char_u *)"";
7021- }
7022-
7023- if (prt_out_mbyte)
7024- {
7025- /* Multi-byte character strings are represented more efficiently as hex
7026- * strings when outputting clean 8 bit PS.
7027- */
7028- do
7029- {
7030- ch = prt_hexchar[(unsigned)(*p) >> 4];
7031- ga_append(&prt_ps_buffer, ch);
7032- ch = prt_hexchar[(*p) & 0xf];
7033- ga_append(&prt_ps_buffer, ch);
7034- p++;
7035- }
7036- while (--len);
7037- }
7038- else
7039-#endif
7040- {
7041- /* Add next character to buffer of characters to output.
7042- * Note: One printed character may require several PS characters to
7043- * represent it, but we only count them as one printed character.
7044- */
7045- ch = *p;
7046- if (ch < 32 || ch == '(' || ch == ')' || ch == '\\')
7047- {
7048- /* Convert non-printing characters to either their escape or octal
7049- * sequence, ensures PS sent over a serial line does not interfere
7050- * with the comms protocol. Note: For EBCDIC we need to write out
7051- * the escape sequences as ASCII codes!
7052- * Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK!
7053- */
7054- ga_append(&prt_ps_buffer, IF_EB('\\', 0134));
7055- switch (ch)
7056- {
7057- case BS: ga_append(&prt_ps_buffer, IF_EB('b', 0142)); break;
7058- case TAB: ga_append(&prt_ps_buffer, IF_EB('t', 0164)); break;
7059- case NL: ga_append(&prt_ps_buffer, IF_EB('n', 0156)); break;
7060- case FF: ga_append(&prt_ps_buffer, IF_EB('f', 0146)); break;
7061- case CAR: ga_append(&prt_ps_buffer, IF_EB('r', 0162)); break;
7062- case '(': ga_append(&prt_ps_buffer, IF_EB('(', 0050)); break;
7063- case ')': ga_append(&prt_ps_buffer, IF_EB(')', 0051)); break;
7064- case '\\': ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); break;
7065-
7066- default:
7067- sprintf((char *)ch_buff, "%03o", (unsigned int)ch);
7068-#ifdef EBCDIC
7069- ebcdic2ascii(ch_buff, 3);
7070-#endif
7071- ga_append(&prt_ps_buffer, ch_buff[0]);
7072- ga_append(&prt_ps_buffer, ch_buff[1]);
7073- ga_append(&prt_ps_buffer, ch_buff[2]);
7074- break;
7075- }
7076- }
7077- else
7078- ga_append(&prt_ps_buffer, ch);
7079- }
7080-
7081-#ifdef FEAT_MBYTE
7082- /* Need to free any translated characters */
7083- if (prt_do_conv && (*p != NUL))
7084- vim_free(p);
7085-#endif
7086-
7087- prt_text_run += char_width;
7088- prt_pos_x += char_width;
7089-
7090- /* The downside of fp - use relative error on right margin check */
7091- next_pos = prt_pos_x + prt_char_width;
7092- need_break = (next_pos > prt_right_margin) &&
7093- ((next_pos - prt_right_margin) > (prt_right_margin*1e-5));
7094-
7095- if (need_break)
7096- prt_flush_buffer();
7097-
7098- return need_break;
7099-}
7100-
7101- void
7102-mch_print_set_font(iBold, iItalic, iUnderline)
7103- int iBold;
7104- int iItalic;
7105- int iUnderline;
7106-{
7107- int font = 0;
7108-
7109- if (iBold)
7110- font |= 0x01;
7111- if (iItalic)
7112- font |= 0x02;
7113-
7114- if (font != prt_font)
7115- {
7116- prt_font = font;
7117- prt_attribute_change = TRUE;
7118- prt_need_font = TRUE;
7119- }
7120- if (prt_underline != iUnderline)
7121- {
7122- prt_underline = iUnderline;
7123- prt_attribute_change = TRUE;
7124- prt_need_underline = TRUE;
7125- }
7126-}
7127-
7128- void
7129-mch_print_set_bg(bgcol)
7130- long_u bgcol;
7131-{
7132- prt_bgcol = bgcol;
7133- prt_attribute_change = TRUE;
7134- prt_need_bgcol = TRUE;
7135-}
7136-
7137- void
7138-mch_print_set_fg(fgcol)
7139- long_u fgcol;
7140-{
7141- if (fgcol != (long_u)prt_fgcol)
7142- {
7143- prt_fgcol = fgcol;
7144- prt_attribute_change = TRUE;
7145- prt_need_fgcol = TRUE;
7146- }
7147-}
7148-
7149-# endif /*FEAT_POSTSCRIPT*/
7150-#endif /*FEAT_PRINTER*/
7151-
71523630 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
71533631 && (defined(FEAT_EVAL) || defined(FEAT_MULTI_LANG))
71543632 static char *get_locale_val __ARGS((int what));
diff -r 8d2b705a5a51 -r eb531146be0e src/globals.h
--- a/src/globals.h Fri Jul 22 21:54:43 2005 +0000
+++ b/src/globals.h Sat Jul 23 22:25:46 2005 +0000
@@ -1080,6 +1080,9 @@
10801080 #endif
10811081
10821082 #ifdef FEAT_PRINTER
1083+/*
1084+ * Printer stuff shared between hardcopy.c and machine-specific printing code.
1085+ */
10831086 # define OPT_PRINT_TOP 0
10841087 # define OPT_PRINT_BOT 1
10851088 # define OPT_PRINT_LEFT 2
@@ -1126,34 +1129,11 @@
11261129 # define PRT_UNIT_MM 2
11271130 # define PRT_UNIT_POINT 3
11281131 # define PRT_UNIT_NAMES {"pc", "in", "mm", "pt"}
1129-
1130-# ifdef FEAT_MBYTE
1131-# define OPT_MBFONT_USECOURIER 0
1132-# define OPT_MBFONT_ASCII 1
1133-# define OPT_MBFONT_REGULAR 2
1134-# define OPT_MBFONT_BOLD 3
1135-# define OPT_MBFONT_OBLIQUE 4
1136-# define OPT_MBFONT_BOLDOBLIQUE 5
1137-# define OPT_MBFONT_NUM_OPTIONS 6
1138-#
1139-EXTERN option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS]
1140-# ifdef DO_INIT
1141- =
1142-{
1143- {"c", FALSE, 0, NULL, 0, FALSE},
1144- {"a", FALSE, 0, NULL, 0, FALSE},
1145- {"r", FALSE, 0, NULL, 0, FALSE},
1146- {"b", FALSE, 0, NULL, 0, FALSE},
1147- {"i", FALSE, 0, NULL, 0, FALSE},
1148- {"o", FALSE, 0, NULL, 0, FALSE},
1149-}
1150-# endif
1151-;
1152-# endif
11531132 #endif
11541133
11551134 #ifdef FEAT_XCLIPBOARD
1156-EXTERN char *xterm_display INIT(= NULL); /* xterm display name */
1135+EXTERN char *xterm_display INIT(= NULL); /* xterm display name; points
1136+ into argv[] */
11571137 EXTERN Display *xterm_dpy INIT(= NULL); /* xterm display pointer */
11581138 #endif
11591139 #if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11)
diff -r 8d2b705a5a51 -r eb531146be0e src/main.c
--- a/src/main.c Fri Jul 22 21:54:43 2005 +0000
+++ b/src/main.c Sat Jul 23 22:25:46 2005 +0000
@@ -29,6 +29,15 @@
2929 # include <limits.h>
3030 #endif
3131
32+/* Struct for various parameters passed between main() and other functions. */
33+typedef struct
34+{
35+ int serverArg; /* TRUE when argument for a server */
36+ char_u *serverName_arg; /* cmdline arg for server name */
37+ int evim_mode; /* started as "evim" */
38+ char_u *use_vimrc; /* vimrc from -u option */
39+} mparm_T;
40+
3241 #if defined(UNIX) || defined(VMS)
3342 static int file_owned __ARGS((char *fname));
3443 #endif
@@ -36,6 +45,9 @@
3645 static void main_msg __ARGS((char *s));
3746 static void usage __ARGS((void));
3847 static int get_number_arg __ARGS((char_u *p, int *idx, int def));
48+static void early_arg_scan __ARGS((int argc, char **argv, mparm_T *parmp));
49+static void exe_pre_commands __ARGS((char_u **cmds, int cnt));
50+static void source_startup_scripts __ARGS((mparm_T *parmp));
3951 static void main_start_gui __ARGS((void));
4052 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
4153 static void check_swap_exists_action __ARGS((void));
@@ -50,8 +62,6 @@
5062 static FILE *time_fd = NULL;
5163 #endif
5264
53-#define FEAT_PRECOMMANDS
54-
5565 /*
5666 * Different types of error messages.
5767 */
@@ -95,7 +105,6 @@
95105 char_u *term = NULL; /* specified terminal name */
96106 char_u *fname = NULL; /* file name from command line */
97107 char_u *tagname = NULL; /* tag from -t option */
98- char_u *use_vimrc = NULL; /* vimrc from -u option */
99108 #ifdef FEAT_QUICKFIX
100109 char_u *use_ef = NULL; /* 'errorfile' from -q option */
101110 #endif
@@ -105,10 +114,8 @@
105114 int n_commands = 0; /* no. of commands from + or -c */
106115 char_u *commands[MAX_ARG_CMDS]; /* commands from + or -c option */
107116 char_u cmds_tofree[MAX_ARG_CMDS]; /* commands that need free() */
108-#ifdef FEAT_PRECOMMANDS
109- int p_commands = 0; /* no. of commands from --cmd */
117+ int n_pre_commands = 0; /* no. of commands from --cmd */
110118 char_u *pre_commands[MAX_ARG_CMDS]; /* commands from --cmd option */
111-#endif
112119 int no_swap_file = FALSE; /* "-n" option used */
113120 int c;
114121 int i;
@@ -135,7 +142,6 @@
135142 #ifdef FEAT_DIFF
136143 int diff_mode = FALSE; /* start with 'diff' set */
137144 #endif
138- int evim_mode = FALSE; /* started as "evim" */
139145 int stdout_isatty; /* is stdout a terminal? */
140146 int input_isatty; /* is active input a terminal? */
141147 #ifdef MSWIN
@@ -144,13 +150,13 @@
144150 #ifdef FEAT_CLIENTSERVER
145151 char_u *serverStr = NULL; /* remote server command */
146152 char_u *serverStrEnc = NULL; /* encoding of serverStr */
147- char_u *serverName_arg = NULL; /* cmdline arg for server name */
148- int serverArg = FALSE; /* TRUE when argument for a server */
149153 char_u *servername = NULL; /* allocated name for our server */
150154 #endif
151155 #if (!defined(UNIX) && !defined(__EMX__)) || defined(ARCHIE)
152156 int literal = FALSE; /* don't expand file names */
153157 #endif
158+ mparm_T params; /* various parameters passed between
159+ * main() and other functions. */
154160
155161 /*
156162 * Do any system-specific initialisations. These can NOT use IObuff or
@@ -158,6 +164,8 @@
158164 */
159165 mch_early_init();
160166
167+ vim_memset(&params, 0, sizeof(params));
168+
161169 #ifdef FEAT_TCL
162170 vim_tcl_init(argv[0]);
163171 #endif
@@ -198,7 +206,7 @@
198206 init_normal_cmds();
199207
200208 #if defined(HAVE_DATE_TIME) && defined(VMS) && defined(VAXC)
201- make_version();
209+ make_version(); /* Construct the long version string. */
202210 #endif
203211
204212 /*
@@ -255,75 +263,13 @@
255263 gui.dofork = TRUE; /* default is to use fork() */
256264 #endif
257265
258-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
259266 /*
260- * Get the name of the display, before gui_prepare() removes it from
261- * argv[]. Used for the xterm-clipboard display.
262- *
263- * Also find the --server... arguments
267+ * Do a first scan of the arguments in "argv[]":
268+ * -display
269+ * --server...
270+ * --socketid
264271 */
265- for (i = 1; i < argc; i++)
266- {
267- if (STRCMP(argv[i], "--") == 0)
268- break;
269-# ifdef FEAT_XCLIPBOARD
270- else if (STRICMP(argv[i], "-display") == 0
271-# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
272- || STRICMP(argv[i], "--display") == 0
273-# endif
274- )
275- {
276- if (i == argc - 1)
277- mainerr_arg_missing((char_u *)argv[i]);
278- xterm_display = argv[++i];
279- }
280-# endif
281-# ifdef FEAT_CLIENTSERVER
282- else if (STRICMP(argv[i], "--servername") == 0)
283- {
284- if (i == argc - 1)
285- mainerr_arg_missing((char_u *)argv[i]);
286- serverName_arg = (char_u *)argv[++i];
287- }
288- else if (STRICMP(argv[i], "--serverlist") == 0
289- || STRICMP(argv[i], "--remote-send") == 0
290- || STRICMP(argv[i], "--remote-expr") == 0
291- || STRICMP(argv[i], "--remote") == 0
292- || STRICMP(argv[i], "--remote-silent") == 0)
293- serverArg = TRUE;
294- else if (STRICMP(argv[i], "--remote-wait") == 0
295- || STRICMP(argv[i], "--remote-wait-silent") == 0)
296- {
297- serverArg = TRUE;
298-#ifdef FEAT_GUI
299- /* don't fork() when starting the GUI to edit the files ourself */
300- gui.dofork = FALSE;
301-#endif
302- }
303-# endif
304-# ifdef FEAT_GUI_GTK
305- else if (STRICMP(argv[i], "--socketid") == 0)
306- {
307- unsigned int socket_id;
308- int count;
309-
310- if (i == argc - 1)
311- mainerr_arg_missing((char_u *)argv[i]);
312- if (STRNICMP(argv[i+1], "0x", 2) == 0)
313- count = sscanf(&(argv[i + 1][2]), "%x", &socket_id);
314- else
315- count = sscanf(argv[i+1], "%u", &socket_id);
316- if (count != 1)
317- mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
318- else
319- gtk_socket_id = socket_id;
320- i++;
321- }
322- else if (STRICMP(argv[i], "--echo-wid") == 0)
323- echo_wid_arg = TRUE;
324-# endif
325- }
326-#endif
272+ early_arg_scan(argc, argv, &params);
327273
328274 #ifdef FEAT_SUN_WORKSHOP
329275 findYourself(argv[0]);
@@ -376,7 +322,7 @@
376322 /*
377323 * Do the client-server stuff, unless "--servername ''" was used.
378324 */
379- if (serverName_arg == NULL || *serverName_arg != NUL)
325+ if (params.serverName_arg == NULL || *params.serverName_arg != NUL)
380326 {
381327 # ifdef WIN32
382328 /* Initialise the client/server messaging infrastructure. */
@@ -388,9 +334,9 @@
388334 * exit Vim when it was successful. Otherwise it's executed further
389335 * on. Remember the encoding used here in "serverStrEnc".
390336 */
391- if (serverArg)
337+ if (params.serverArg)
392338 {
393- cmdsrv_main(&argc, argv, serverName_arg, &serverStr);
339+ cmdsrv_main(&argc, argv, params.serverName_arg, &serverStr);
394340 # ifdef FEAT_MBYTE
395341 serverStrEnc = vim_strsave(p_enc);
396342 # endif
@@ -399,7 +345,7 @@
399345 /* If we're still running, get the name to register ourselves.
400346 * On Win32 can register right now, for X11 need to setup the
401347 * clipboard first, it's further down. */
402- servername = serverMakeName(serverName_arg, argv[0]);
348+ servername = serverMakeName(params.serverName_arg, argv[0]);
403349 # ifdef WIN32
404350 if (servername != NULL)
405351 {
@@ -453,7 +399,7 @@
453399 #ifdef FEAT_GUI
454400 gui.starting = TRUE;
455401 #endif
456- evim_mode = TRUE;
402+ params.evim_mode = TRUE;
457403 ++initstr;
458404 }
459405
@@ -588,13 +534,11 @@
588534 }
589535 else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0)
590536 p_lpl = FALSE;
591-#ifdef FEAT_PRECOMMANDS
592537 else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0)
593538 {
594539 want_argument = TRUE;
595540 argv_idx += 3;
596541 }
597-#endif
598542 #ifdef FEAT_CLIENTSERVER
599543 else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0)
600544 ; /* already processed -- no arg */
@@ -724,7 +668,7 @@
724668 #ifdef FEAT_GUI
725669 gui.starting = TRUE; /* start GUI a bit later */
726670 #endif
727- evim_mode = TRUE;
671+ params.evim_mode = TRUE;
728672 break;
729673
730674 case 'N': /* "-N" Nocompatible */
@@ -940,13 +884,11 @@
940884 commands[n_commands++] = (char_u *)argv[0];
941885 break;
942886
943-#ifdef FEAT_PRECOMMANDS
944887 case '-': /* "--cmd {command}" execute command */
945- if (p_commands >= MAX_ARG_CMDS)
888+ if (n_pre_commands >= MAX_ARG_CMDS)
946889 mainerr(ME_EXTRA_CMD, NULL);
947- pre_commands[p_commands++] = (char_u *)argv[0];
890+ pre_commands[n_pre_commands++] = (char_u *)argv[0];
948891 break;
949-#endif
950892
951893 /* case 'd': -d {device} is handled in mch_check_win() for the
952894 * Amiga */
@@ -1002,7 +944,7 @@
1002944 break;
1003945
1004946 case 'u': /* "-u {vimrc}" vim inits file */
1005- use_vimrc = (char_u *)argv[0];
947+ params.use_vimrc = (char_u *)argv[0];
1006948 break;
1007949
1008950 case 'U': /* "-U {gvimrc}" gvim inits file */
@@ -1151,7 +1093,7 @@
11511093
11521094 /* When running "evim" or "gvim -y" we need the menus, exit if we
11531095 * don't have them. */
1154- if (evim_mode)
1096+ if (params.evim_mode)
11551097 mch_exit(1);
11561098 }
11571099 # endif
@@ -1365,176 +1307,17 @@
13651307
13661308 init_highlight(TRUE, FALSE); /* set the default highlight groups */
13671309 TIME_MSG("init highlight");
1368-#ifdef CURSOR_SHAPE
1369- parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
1370-#endif
1371-#ifdef FEAT_MOUSESHAPE
1372- parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
1373-#endif
1374-#ifdef FEAT_PRINTER
1375- parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS);
1376-#endif
13771310
13781311 #ifdef FEAT_EVAL
13791312 /* Set the break level after the terminal is initialized. */
13801313 debug_break_level = use_debug_break_level;
13811314 #endif
13821315
1383-#ifdef FEAT_PRECOMMANDS
1384- if (p_commands > 0)
1385- {
1386- curwin->w_cursor.lnum = 0; /* just in case.. */
1387- sourcing_name = (char_u *)_("pre-vimrc command line");
1388-# ifdef FEAT_EVAL
1389- current_SID = SID_CMDARG;
1390-# endif
1391- for (i = 0; i < p_commands; ++i)
1392- do_cmdline_cmd(pre_commands[i]);
1393- sourcing_name = NULL;
1394-# ifdef FEAT_EVAL
1395- current_SID = 0;
1396-# endif
1397- }
1398-#endif
1399-
1400- /*
1401- * For "evim" source evim.vim first of all, so that the user can overrule
1402- * any things he doesn't like.
1403- */
1404- if (evim_mode)
1405- {
1406- (void)do_source((char_u *)EVIM_FILE, FALSE, FALSE);
1407- TIME_MSG("source evim file");
1408- }
1409-
1410- /*
1411- * If -u option given, use only the initializations from that file and
1412- * nothing else.
1413- */
1414- if (use_vimrc != NULL)
1415- {
1416- if (STRCMP(use_vimrc, "NONE") == 0 || STRCMP(use_vimrc, "NORC") == 0)
1417- {
1418-#ifdef FEAT_GUI
1419- if (use_gvimrc == NULL) /* don't load gvimrc either */
1420- use_gvimrc = use_vimrc;
1421-#endif
1422- if (use_vimrc[2] == 'N')
1423- p_lpl = FALSE; /* don't load plugins either */
1424- }
1425- else
1426- {
1427- if (do_source(use_vimrc, FALSE, FALSE) != OK)
1428- EMSG2(_("E282: Cannot read from \"%s\""), use_vimrc);
1429- }
1430- }
1431- else if (!silent_mode)
1432- {
1433-#ifdef AMIGA
1434- struct Process *proc = (struct Process *)FindTask(0L);
1435- APTR save_winptr = proc->pr_WindowPtr;
1436-
1437- /* Avoid a requester here for a volume that doesn't exist. */
1438- proc->pr_WindowPtr = (APTR)-1L;
1439-#endif
1440-
1441- /*
1442- * Get system wide defaults, if the file name is defined.
1443- */
1444-#ifdef SYS_VIMRC_FILE
1445- (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, FALSE);
1446-#endif
1447-
1448- /*
1449- * Try to read initialization commands from the following places:
1450- * - environment variable VIMINIT
1451- * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise)
1452- * - second user vimrc file ($VIM/.vimrc for Dos)
1453- * - environment variable EXINIT
1454- * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise)
1455- * - second user exrc file ($VIM/.exrc for Dos)
1456- * The first that exists is used, the rest is ignored.
1457- */
1458- if (process_env((char_u *)"VIMINIT", TRUE) != OK)
1459- {
1460- if (do_source((char_u *)USR_VIMRC_FILE, TRUE, TRUE) == FAIL
1461-#ifdef USR_VIMRC_FILE2
1462- && do_source((char_u *)USR_VIMRC_FILE2, TRUE, TRUE) == FAIL
1463-#endif
1464-#ifdef USR_VIMRC_FILE3
1465- && do_source((char_u *)USR_VIMRC_FILE3, TRUE, TRUE) == FAIL
1466-#endif
1467- && process_env((char_u *)"EXINIT", FALSE) == FAIL
1468- && do_source((char_u *)USR_EXRC_FILE, FALSE, FALSE) == FAIL)
1469- {
1470-#ifdef USR_EXRC_FILE2
1471- (void)do_source((char_u *)USR_EXRC_FILE2, FALSE, FALSE);
1472-#endif
1473- }
1474- }
1475-
1476- /*
1477- * Read initialization commands from ".vimrc" or ".exrc" in current
1478- * directory. This is only done if the 'exrc' option is set.
1479- * Because of security reasons we disallow shell and write commands
1480- * now, except for unix if the file is owned by the user or 'secure'
1481- * option has been reset in environment of global ".exrc" or ".vimrc".
1482- * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or
1483- * SYS_VIMRC_FILE.
1484- */
1485- if (p_exrc)
1486- {
1487-#if defined(UNIX) || defined(VMS)
1488- /* If ".vimrc" file is not owned by user, set 'secure' mode. */
1489- if (!file_owned(VIMRC_FILE))
1490-#endif
1491- secure = p_secure;
1492-
1493- i = FAIL;
1494- if (fullpathcmp((char_u *)USR_VIMRC_FILE,
1495- (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
1496-#ifdef USR_VIMRC_FILE2
1497- && fullpathcmp((char_u *)USR_VIMRC_FILE2,
1498- (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
1499-#endif
1500-#ifdef USR_VIMRC_FILE3
1501- && fullpathcmp((char_u *)USR_VIMRC_FILE3,
1502- (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
1503-#endif
1504-#ifdef SYS_VIMRC_FILE
1505- && fullpathcmp((char_u *)SYS_VIMRC_FILE,
1506- (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
1507-#endif
1508- )
1509- i = do_source((char_u *)VIMRC_FILE, TRUE, TRUE);
1510-
1511- if (i == FAIL)
1512- {
1513-#if defined(UNIX) || defined(VMS)
1514- /* if ".exrc" is not owned by user set 'secure' mode */
1515- if (!file_owned(EXRC_FILE))
1516- secure = p_secure;
1517- else
1518- secure = 0;
1519-#endif
1520- if ( fullpathcmp((char_u *)USR_EXRC_FILE,
1521- (char_u *)EXRC_FILE, FALSE) != FPC_SAME
1522-#ifdef USR_EXRC_FILE2
1523- && fullpathcmp((char_u *)USR_EXRC_FILE2,
1524- (char_u *)EXRC_FILE, FALSE) != FPC_SAME
1525-#endif
1526- )
1527- (void)do_source((char_u *)EXRC_FILE, FALSE, FALSE);
1528- }
1529- }
1530- if (secure == 2)
1531- need_wait_return = TRUE;
1532- secure = 0;
1533-#ifdef AMIGA
1534- proc->pr_WindowPtr = save_winptr;
1535-#endif
1536- }
1537- TIME_MSG("sourcing vimrc file(s)");
1316+ /* Execute --cmd arguments. */
1317+ exe_pre_commands(pre_commands, n_pre_commands);
1318+
1319+ /* Source startup scripts. */
1320+ source_startup_scripts(&params);
15381321
15391322 #ifdef FEAT_EVAL
15401323 /*
@@ -1599,7 +1382,7 @@
15991382
16001383 /* When running "evim" or "gvim -y" we need the menus, exit if we
16011384 * don't have them. */
1602- if (!gui.in_use && evim_mode)
1385+ if (!gui.in_use && params.evim_mode)
16031386 mch_exit(1);
16041387 }
16051388 #endif
@@ -1690,7 +1473,7 @@
16901473 # ifdef FEAT_GUI
16911474 gui.in_use ||
16921475 # endif
1693- serverName_arg != NULL))
1476+ params.serverName_arg != NULL))
16941477 {
16951478 (void)serverRegisterName(X_DISPLAY, servername);
16961479 vim_free(servername);
@@ -1778,8 +1561,7 @@
17781561 #endif
17791562 if (scroll_region)
17801563 scroll_region_reset(); /* In case Rows changed */
1781-
1782- scroll_start();
1564+ scroll_start(); /* may scroll the screen to the right position */
17831565
17841566 /*
17851567 * Don't clear the screen when starting in Ex mode, unless using the GUI.
@@ -2439,6 +2221,262 @@
24392221 }
24402222
24412223 /*
2224+ * Get the name of the display, before gui_prepare() removes it from
2225+ * argv[]. Used for the xterm-clipboard display.
2226+ *
2227+ * Also find the --server... arguments and --socketid
2228+ */
2229+/*ARGSUSED*/
2230+ static void
2231+early_arg_scan(argc, argv, parmp)
2232+ int argc;
2233+ char **argv;
2234+ mparm_T *parmp;
2235+{
2236+#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
2237+ int i;
2238+
2239+ for (i = 1; i < argc; i++)
2240+ {
2241+ if (STRCMP(argv[i], "--") == 0)
2242+ break;
2243+# ifdef FEAT_XCLIPBOARD
2244+ else if (STRICMP(argv[i], "-display") == 0
2245+# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
2246+ || STRICMP(argv[i], "--display") == 0
2247+# endif
2248+ )
2249+ {
2250+ if (i == argc - 1)
2251+ mainerr_arg_missing((char_u *)argv[i]);
2252+ xterm_display = argv[++i];
2253+ }
2254+# endif
2255+# ifdef FEAT_CLIENTSERVER
2256+ else if (STRICMP(argv[i], "--servername") == 0)
2257+ {
2258+ if (i == argc - 1)
2259+ mainerr_arg_missing((char_u *)argv[i]);
2260+ parmp->serverName_arg = (char_u *)argv[++i];
2261+ }
2262+ else if (STRICMP(argv[i], "--serverlist") == 0
2263+ || STRICMP(argv[i], "--remote-send") == 0
2264+ || STRICMP(argv[i], "--remote-expr") == 0
2265+ || STRICMP(argv[i], "--remote") == 0
2266+ || STRICMP(argv[i], "--remote-silent") == 0)
2267+ parmp->serverArg = TRUE;
2268+ else if (STRICMP(argv[i], "--remote-wait") == 0
2269+ || STRICMP(argv[i], "--remote-wait-silent") == 0)
2270+ {
2271+ parmp->serverArg = TRUE;
2272+#ifdef FEAT_GUI
2273+ /* don't fork() when starting the GUI to edit the files ourself */
2274+ gui.dofork = FALSE;
2275+#endif
2276+ }
2277+# endif
2278+# ifdef FEAT_GUI_GTK
2279+ else if (STRICMP(argv[i], "--socketid") == 0)
2280+ {
2281+ unsigned int socket_id;
2282+ int count;
2283+
2284+ if (i == argc - 1)
2285+ mainerr_arg_missing((char_u *)argv[i]);
2286+ if (STRNICMP(argv[i+1], "0x", 2) == 0)
2287+ count = sscanf(&(argv[i + 1][2]), "%x", &socket_id);
2288+ else
2289+ count = sscanf(argv[i+1], "%u", &socket_id);
2290+ if (count != 1)
2291+ mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
2292+ else
2293+ gtk_socket_id = socket_id;
2294+ i++;
2295+ }
2296+ else if (STRICMP(argv[i], "--echo-wid") == 0)
2297+ echo_wid_arg = TRUE;
2298+# endif
2299+ }
2300+#endif
2301+}
2302+
2303+/*
2304+ * Execute the commands from --cmd arguments "cmds[cnt]".
2305+ */
2306+ static void
2307+exe_pre_commands(cmds, cnt)
2308+ char_u **cmds;
2309+ int cnt;
2310+{
2311+ int i;
2312+
2313+ if (cnt > 0)
2314+ {
2315+ curwin->w_cursor.lnum = 0; /* just in case.. */
2316+ sourcing_name = (char_u *)_("pre-vimrc command line");
2317+# ifdef FEAT_EVAL
2318+ current_SID = SID_CMDARG;
2319+# endif
2320+ for (i = 0; i < cnt; ++i)
2321+ do_cmdline_cmd(cmds[i]);
2322+ sourcing_name = NULL;
2323+# ifdef FEAT_EVAL
2324+ current_SID = 0;
2325+# endif
2326+ TIME_MSG("--cmd commands");
2327+ }
2328+}
2329+
2330+/*
2331+ * Source startup scripts.
2332+ */
2333+ static void
2334+source_startup_scripts(parmp)
2335+ mparm_T *parmp;
2336+{
2337+ int i;
2338+
2339+ /*
2340+ * For "evim" source evim.vim first of all, so that the user can overrule
2341+ * any things he doesn't like.
2342+ */
2343+ if (parmp->evim_mode)
2344+ {
2345+ (void)do_source((char_u *)EVIM_FILE, FALSE, FALSE);
2346+ TIME_MSG("source evim file");
2347+ }
2348+
2349+ /*
2350+ * If -u option given, use only the initializations from that file and
2351+ * nothing else.
2352+ */
2353+ if (parmp->use_vimrc != NULL)
2354+ {
2355+ if (STRCMP(parmp->use_vimrc, "NONE") == 0 || STRCMP(parmp->use_vimrc, "NORC") == 0)
2356+ {
2357+#ifdef FEAT_GUI
2358+ if (use_gvimrc == NULL) /* don't load gvimrc either */
2359+ use_gvimrc = parmp->use_vimrc;
2360+#endif
2361+ if (parmp->use_vimrc[2] == 'N')
2362+ p_lpl = FALSE; /* don't load plugins either */
2363+ }
2364+ else
2365+ {
2366+ if (do_source(parmp->use_vimrc, FALSE, FALSE) != OK)
2367+ EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
2368+ }
2369+ }
2370+ else if (!silent_mode)
2371+ {
2372+#ifdef AMIGA
2373+ struct Process *proc = (struct Process *)FindTask(0L);
2374+ APTR save_winptr = proc->pr_WindowPtr;
2375+
2376+ /* Avoid a requester here for a volume that doesn't exist. */
2377+ proc->pr_WindowPtr = (APTR)-1L;
2378+#endif
2379+
2380+ /*
2381+ * Get system wide defaults, if the file name is defined.
2382+ */
2383+#ifdef SYS_VIMRC_FILE
2384+ (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, FALSE);
2385+#endif
2386+
2387+ /*
2388+ * Try to read initialization commands from the following places:
2389+ * - environment variable VIMINIT
2390+ * - user vimrc file (s:.vimrc for Amiga, ~/.vimrc otherwise)
2391+ * - second user vimrc file ($VIM/.vimrc for Dos)
2392+ * - environment variable EXINIT
2393+ * - user exrc file (s:.exrc for Amiga, ~/.exrc otherwise)
2394+ * - second user exrc file ($VIM/.exrc for Dos)
2395+ * The first that exists is used, the rest is ignored.
2396+ */
2397+ if (process_env((char_u *)"VIMINIT", TRUE) != OK)
2398+ {
2399+ if (do_source((char_u *)USR_VIMRC_FILE, TRUE, TRUE) == FAIL
2400+#ifdef USR_VIMRC_FILE2
2401+ && do_source((char_u *)USR_VIMRC_FILE2, TRUE, TRUE) == FAIL
2402+#endif
2403+#ifdef USR_VIMRC_FILE3
2404+ && do_source((char_u *)USR_VIMRC_FILE3, TRUE, TRUE) == FAIL
2405+#endif
2406+ && process_env((char_u *)"EXINIT", FALSE) == FAIL
2407+ && do_source((char_u *)USR_EXRC_FILE, FALSE, FALSE) == FAIL)
2408+ {
2409+#ifdef USR_EXRC_FILE2
2410+ (void)do_source((char_u *)USR_EXRC_FILE2, FALSE, FALSE);
2411+#endif
2412+ }
2413+ }
2414+
2415+ /*
2416+ * Read initialization commands from ".vimrc" or ".exrc" in current
2417+ * directory. This is only done if the 'exrc' option is set.
2418+ * Because of security reasons we disallow shell and write commands
2419+ * now, except for unix if the file is owned by the user or 'secure'
2420+ * option has been reset in environment of global ".exrc" or ".vimrc".
2421+ * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or
2422+ * SYS_VIMRC_FILE.
2423+ */
2424+ if (p_exrc)
2425+ {
2426+#if defined(UNIX) || defined(VMS)
2427+ /* If ".vimrc" file is not owned by user, set 'secure' mode. */
2428+ if (!file_owned(VIMRC_FILE))
2429+#endif
2430+ secure = p_secure;
2431+
2432+ i = FAIL;
2433+ if (fullpathcmp((char_u *)USR_VIMRC_FILE,
2434+ (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
2435+#ifdef USR_VIMRC_FILE2
2436+ && fullpathcmp((char_u *)USR_VIMRC_FILE2,
2437+ (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
2438+#endif
2439+#ifdef USR_VIMRC_FILE3
2440+ && fullpathcmp((char_u *)USR_VIMRC_FILE3,
2441+ (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
2442+#endif
2443+#ifdef SYS_VIMRC_FILE
2444+ && fullpathcmp((char_u *)SYS_VIMRC_FILE,
2445+ (char_u *)VIMRC_FILE, FALSE) != FPC_SAME
2446+#endif
2447+ )
2448+ i = do_source((char_u *)VIMRC_FILE, TRUE, TRUE);
2449+
2450+ if (i == FAIL)
2451+ {
2452+#if defined(UNIX) || defined(VMS)
2453+ /* if ".exrc" is not owned by user set 'secure' mode */
2454+ if (!file_owned(EXRC_FILE))
2455+ secure = p_secure;
2456+ else
2457+ secure = 0;
2458+#endif
2459+ if ( fullpathcmp((char_u *)USR_EXRC_FILE,
2460+ (char_u *)EXRC_FILE, FALSE) != FPC_SAME
2461+#ifdef USR_EXRC_FILE2
2462+ && fullpathcmp((char_u *)USR_EXRC_FILE2,
2463+ (char_u *)EXRC_FILE, FALSE) != FPC_SAME
2464+#endif
2465+ )
2466+ (void)do_source((char_u *)EXRC_FILE, FALSE, FALSE);
2467+ }
2468+ }
2469+ if (secure == 2)
2470+ need_wait_return = TRUE;
2471+ secure = 0;
2472+#ifdef AMIGA
2473+ proc->pr_WindowPtr = save_winptr;
2474+#endif
2475+ }
2476+ TIME_MSG("sourcing vimrc file(s)");
2477+}
2478+
2479+/*
24422480 * Setup to start using the GUI. Exit with an error when not available.
24432481 */
24442482 static void
@@ -2656,9 +2694,7 @@
26562694 main_msg(_("-O[N]\t\tLike -o but split vertically"));
26572695 main_msg(_("+\t\t\tStart at end of file"));
26582696 main_msg(_("+<lnum>\t\tStart at line <lnum>"));
2659-#ifdef FEAT_PRECOMMANDS
26602697 main_msg(_("--cmd <command>\tExecute <command> before loading any vimrc file"));
2661-#endif
26622698 main_msg(_("-c <command>\t\tExecute <command> after loading the first file"));
26632699 main_msg(_("-S <session>\t\tSource file <session> after loading the first file"));
26642700 main_msg(_("-s <scriptin>\tRead Normal mode commands from file <scriptin>"));
diff -r 8d2b705a5a51 -r eb531146be0e src/misc2.c
--- a/src/misc2.c Fri Jul 22 21:54:43 2005 +0000
+++ b/src/misc2.c Sat Jul 23 22:25:46 2005 +0000
@@ -5557,80 +5557,6 @@
55575557 }
55585558 #endif
55595559
5560-#if defined(FEAT_PRINTER) || defined(PROTO)
5561-/*
5562- * Parse a list of options in the form
5563- * option:value,option:value,option:value
5564- *
5565- * "value" can start with a number which is parsed out, e.g.
5566- * margin:12mm
5567- *
5568- * Returns error message for an illegal option, NULL otherwise.
5569- * Only used for the printer at the moment...
5570- */
5571- char_u *
5572-parse_list_options(option_str, table, table_size)
5573- char_u *option_str;
5574- option_table_T *table;
5575- int table_size;
5576-{
5577- char_u *stringp;
5578- char_u *colonp;
5579- char_u *commap;
5580- char_u *p;
5581- int idx = 0; /* init for GCC */
5582- int len;
5583-
5584- for (idx = 0; idx < table_size; ++idx)
5585- table[idx].present = FALSE;
5586-
5587- /*
5588- * Repeat for all comma separated parts.
5589- */
5590- stringp = option_str;
5591- while (*stringp)
5592- {
5593- colonp = vim_strchr(stringp, ':');
5594- if (colonp == NULL)
5595- return (char_u *)N_("E550: Missing colon");
5596- commap = vim_strchr(stringp, ',');
5597- if (commap == NULL)
5598- commap = option_str + STRLEN(option_str);
5599-
5600- len = (int)(colonp - stringp);
5601-
5602- for (idx = 0; idx < table_size; ++idx)
5603- if (STRNICMP(stringp, table[idx].name, len) == 0)
5604- break;
5605-
5606- if (idx == table_size)
5607- return (char_u *)N_("E551: Illegal component");
5608-
5609- p = colonp + 1;
5610- table[idx].present = TRUE;
5611-
5612- if (table[idx].hasnum)
5613- {
5614- if (!VIM_ISDIGIT(*p))
5615- return (char_u *)N_("E552: digit expected");
5616-
5617- table[idx].number = getdigits(&p); /*advances p*/
5618- }
5619-
5620- table[idx].string = p;
5621- table[idx].strlen = (int)(commap - p);
5622-
5623- stringp = commap;
5624- if (*stringp == ',')
5625- ++stringp;
5626- }
5627-
5628- return NULL;
5629-}
5630-
5631-
5632-#endif /*FEAT_PRINTER*/
5633-
56345560 /*
56355561 * The putenv() implementation below comes from the "screen" program.
56365562 * Included with permission from Juergen Weigert.
diff -r 8d2b705a5a51 -r eb531146be0e src/option.c
--- a/src/option.c Fri Jul 22 21:54:43 2005 +0000
+++ b/src/option.c Sat Jul 23 22:25:46 2005 +0000
@@ -3269,6 +3269,16 @@
32693269 }
32703270 }
32713271 #endif
3272+
3273+#ifdef CURSOR_SHAPE
3274+ parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3275+#endif
3276+#ifdef FEAT_MOUSESHAPE
3277+ parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3278+#endif
3279+#ifdef FEAT_PRINTER
3280+ (void)parse_printoptions(); /* parse 'printoptions' default value */
3281+#endif
32723282 }
32733283
32743284 /*
@@ -5598,13 +5608,10 @@
55985608
55995609 #ifdef FEAT_PRINTER
56005610 else if (varp == &p_popt)
5601- errmsg = parse_list_options(p_popt, printer_opts,
5602- OPT_PRINT_NUM_OPTIONS);
5603-
5611+ errmsg = parse_printoptions();
56045612 # if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
56055613 else if (varp == &p_pmfn)
5606- errmsg = parse_list_options(p_pmfn, mbfont_opts,
5607- OPT_MBFONT_NUM_OPTIONS);
5614+ errmsg = parse_printmbfont();
56085615 # endif
56095616 #endif
56105617
diff -r 8d2b705a5a51 -r eb531146be0e src/os_mswin.c
--- a/src/os_mswin.c Fri Jul 22 21:54:43 2005 +0000
+++ b/src/os_mswin.c Sat Jul 23 22:25:46 2005 +0000
@@ -2357,6 +2357,8 @@
23572357
23582358 #endif /*FEAT_PRINTER && !FEAT_POSTSCRIPT*/
23592359
2360+
2361+
23602362 #if defined(FEAT_SHORTCUT) || defined(PROTO)
23612363 # include <shlobj.h>
23622364
diff -r 8d2b705a5a51 -r eb531146be0e src/po/Makefile
--- a/src/po/Makefile Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/Makefile Sat Jul 23 22:25:46 2005 +0000
@@ -52,8 +52,49 @@
5252 zh_TW.UTF-8.mo \
5353 zh_TW.mo \
5454
55+CONVERTED = \
56+ cs.cp1250.mo \
57+ ja.sjis.mo \
58+ pl.cp1250.mo \
59+ ru.cp1251.mo \
60+ sk.cp1250.mo \
61+ uk.cp1251.mo \
62+ zh_CN.cp936.mo \
63+
64+CHECKFILES = \
65+ af.ck \
66+ ca.ck \
67+ cs.ck \
68+ de.ck \
69+ en_GB.ck \
70+ es.ck \
71+ fr.ck \
72+ ga.ck \
73+ it.ck \
74+ ja.ck \
75+ ko.ck \
76+ no.ck \
77+ pl.ck \
78+ ru.ck \
79+ sk.ck \
80+ sv.ck \
81+ uk.ck \
82+ vi.ck \
83+ zh_CN.UTF-8.ck \
84+ zh_CN.ck \
85+ zh_TW.UTF-8.ck \
86+ zh_TW.ck \
87+ cs.cp1250.ck \
88+ ja.sjis.ck \
89+ pl.cp1250.ck \
90+ ru.cp1251.ck \
91+ sk.cp1250.ck \
92+ uk.cp1251.ck \
93+ zh_CN.cp936.ck \
94+
5595 PACKAGE = vim
5696 SHELL = /bin/sh
97+VIM = ../vim
5798
5899 # The OLD_PO_FILE_INPUT and OLD_PO_FILE_OUTPUT are for the new GNU gettext
59100 # tools 0.10.37, which use a slightly different .po file format that is not
@@ -64,16 +105,22 @@
64105 MSGMERGE = OLD_PO_FILE_INPUT=yes OLD_PO_FILE_OUTPUT=yes msgmerge
65106
66107 .SUFFIXES:
67-.SUFFIXES: .po .mo .pot
68-.PHONY: all install uninstall check clean distclean $(LANGUAGES)
108+.SUFFIXES: .po .mo .pot .ck
109+.PHONY: all install uninstall prefixcheck check clean distclean $(LANGUAGES)
69110
70111 .po.mo:
71112 $(MSGFMT) -o $@ $<
72113
114+.po.ck:
115+ $(VIM) -u NONE -e -S check.vim -c "if error == 0 | q | endif" -c cq $<
116+ touch $@
117+
73118 all: $(MOFILES)
74119
120+check: $(CHECKFILES)
121+
75122 install: $(MOFILES)
76- @$(MAKE) check
123+ @$(MAKE) prefixcheck
77124 for lang in $(LANGUAGES); do \
78125 dir=$(LOCALEDIR)/$$lang/; \
79126 if test ! -x "$$dir"; then \
@@ -90,21 +137,14 @@
90137 done
91138
92139 uninstall:
93- @$(MAKE) check
140+ @$(MAKE) prefixcheck
94141 for cat in $(MOFILES); do \
95142 cat=`basename $$cat`; \
96143 lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
97144 rm -f $(LOCALEDIR)/$$lang/LC_MESSAGES/$(PACKAGE).mo; \
98145 done
99146
100-converted: \
101- cs.cp1250.mo \
102- ja.sjis.mo \
103- pl.cp1250.mo \
104- ru.cp1251.mo \
105- sk.cp1250.mo \
106- uk.cp1251.mo \
107- zh_CN.cp936.mo \
147+converted: $(CONVERTED)
108148
109149 # Convert ja.po to create ja.sjis.po. Requires doubling backslashes in the
110150 # second byte. Don't depend on sjiscorr, it should only be compiled when
@@ -154,7 +194,7 @@
154194 iconv -f koi8-u -t cp1251 uk.po | \
155195 sed -e 's/charset=koi8-u/charset=cp1251/' -e 's/# Original translations/# Generated from uk.po, DO NOT EDIT/' > uk.cp1251.po
156196
157-check:
197+prefixcheck:
158198 @if test "x" = "x$(prefix)"; then \
159199 echo "******************************************"; \
160200 echo " please use make from the src directory "; \
@@ -163,7 +203,7 @@
163203 fi
164204
165205 clean:
166- rm -f core core.* *.old.po *.mo *.pot sjiscorr
206+ rm -f core core.* *.old.po *.mo *.ck *.pot sjiscorr
167207
168208 distclean: clean
169209
diff -r 8d2b705a5a51 -r eb531146be0e src/po/README.txt
--- a/src/po/README.txt Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/README.txt Sat Jul 23 22:25:46 2005 +0000
@@ -99,6 +99,7 @@
9999
100100 (4) Check:
101101
102+ vim -S check.vim xx.po
102103 make xx.mo
103104
104105 Look out for syntax errors and fix them.
diff -r 8d2b705a5a51 -r eb531146be0e src/po/README_mingw.txt
--- a/src/po/README_mingw.txt Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/README_mingw.txt Sat Jul 23 22:25:46 2005 +0000
@@ -74,6 +74,7 @@
7474
7575 (4) Check:
7676
77+ vim -S check.vim xx.po
7778 make -f Make_ming.mak xx.mo
7879
7980 Look out for syntax errors and fix them.
diff -r 8d2b705a5a51 -r eb531146be0e src/po/cs.cp1250.po
--- a/src/po/cs.cp1250.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/cs.cp1250.po Sat Jul 23 22:25:46 2005 +0000
@@ -2351,12 +2351,12 @@
23512351 #: if_python.c:1824
23522352 #, c-format
23532353 msgid "<window object (deleted) at %.8lX>"
2354-msgstr "<objekt okna (smazán) na %8lX>"
2354+msgstr "<objekt okna (smazán) na %.8lX>"
23552355
23562356 #: if_python.c:1836
23572357 #, c-format
23582358 msgid "<window object (unknown) at %.8lX>"
2359-msgstr "<objekt okna (neznámý) na %8lX>"
2359+msgstr "<objekt okna (neznámý) na %.8lX>"
23602360
23612361 #: if_python.c:1838
23622362 #, c-format
diff -r 8d2b705a5a51 -r eb531146be0e src/po/cs.po
--- a/src/po/cs.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/cs.po Sat Jul 23 22:25:46 2005 +0000
@@ -2351,12 +2351,12 @@
23512351 #: if_python.c:1824
23522352 #, c-format
23532353 msgid "<window object (deleted) at %.8lX>"
2354-msgstr "<objekt okna (smazán) na %8lX>"
2354+msgstr "<objekt okna (smazán) na %.8lX>"
23552355
23562356 #: if_python.c:1836
23572357 #, c-format
23582358 msgid "<window object (unknown) at %.8lX>"
2359-msgstr "<objekt okna (neznámý) na %8lX>"
2359+msgstr "<objekt okna (neznámý) na %.8lX>"
23602360
23612361 #: if_python.c:1838
23622362 #, c-format
diff -r 8d2b705a5a51 -r eb531146be0e src/po/uk.cp1251.po
--- a/src/po/uk.cp1251.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/uk.cp1251.po Sat Jul 23 22:25:46 2005 +0000
@@ -729,7 +729,7 @@
729729
730730 #: ex_cmds2.c:2913
731731 msgid "Printing page %d (%d%%)"
732-msgstr "Äðóêóºòüñÿ ñòîð³íêà %d (%d)"
732+msgstr "Äðóêóºòüñÿ ñòîð³íêà %d (%d%%)"
733733
734734 #: ex_cmds2.c:2922
735735 #, c-format
@@ -894,7 +894,7 @@
894894 #: ex_cmds.c:2244
895895 #, c-format
896896 msgid "Overwrite existing file \"%.*s\"?"
897-msgstr "Ïåðåçàïèñàòè ³ñíóþ÷èé ôàéë \"%*.s\"?"
897+msgstr "Ïåðåçàïèñàòè ³ñíóþ÷èé ôàéë \"%.*s\"?"
898898
899899 #: ex_cmds.c:2315
900900 #, c-format
diff -r 8d2b705a5a51 -r eb531146be0e src/po/uk.po
--- a/src/po/uk.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/uk.po Sat Jul 23 22:25:46 2005 +0000
@@ -729,7 +729,7 @@
729729
730730 #: ex_cmds2.c:2913
731731 msgid "Printing page %d (%d%%)"
732-msgstr "äÒÕËÕ¤ÔØÓÑ ÓÔÏÒ¦ÎËÁ %d (%d)"
732+msgstr "äÒÕËÕ¤ÔØÓÑ ÓÔÏÒ¦ÎËÁ %d (%d%%)"
733733
734734 #: ex_cmds2.c:2922
735735 #, c-format
@@ -894,7 +894,7 @@
894894 #: ex_cmds.c:2244
895895 #, c-format
896896 msgid "Overwrite existing file \"%.*s\"?"
897-msgstr "ðÅÒÅÚÁÐÉÓÁÔÉ ¦ÓÎÕÀÞÉÊ ÆÁÊÌ \"%*.s\"?"
897+msgstr "ðÅÒÅÚÁÐÉÓÁÔÉ ¦ÓÎÕÀÞÉÊ ÆÁÊÌ \"%.*s\"?"
898898
899899 #: ex_cmds.c:2315
900900 #, c-format
diff -r 8d2b705a5a51 -r eb531146be0e src/po/zh_CN.UTF-8.po
--- a/src/po/zh_CN.UTF-8.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/zh_CN.UTF-8.po Sat Jul 23 22:25:46 2005 +0000
@@ -2118,7 +2118,7 @@
21182118 #: if_cscope.c:26
21192119 #, c-format
21202120 msgid "Usage: cs[cope] %s"
2121-msgstr ""
2121+msgstr "Usage: cs[cope] %s"
21222122
21232123 #: if_cscope.c:67
21242124 msgid "Add a new database"
diff -r 8d2b705a5a51 -r eb531146be0e src/po/zh_CN.cp936.po
--- a/src/po/zh_CN.cp936.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/zh_CN.cp936.po Sat Jul 23 22:25:46 2005 +0000
@@ -2118,7 +2118,7 @@
21182118 #: if_cscope.c:26
21192119 #, c-format
21202120 msgid "Usage: cs[cope] %s"
2121-msgstr ""
2121+msgstr "Usage: cs[cope] %s"
21222122
21232123 #: if_cscope.c:67
21242124 msgid "Add a new database"
diff -r 8d2b705a5a51 -r eb531146be0e src/po/zh_CN.po
--- a/src/po/zh_CN.po Fri Jul 22 21:54:43 2005 +0000
+++ b/src/po/zh_CN.po Sat Jul 23 22:25:46 2005 +0000
@@ -2118,7 +2118,7 @@
21182118 #: if_cscope.c:26
21192119 #, c-format
21202120 msgid "Usage: cs[cope] %s"
2121-msgstr ""
2121+msgstr "Usage: cs[cope] %s"
21222122
21232123 #: if_cscope.c:67
21242124 msgid "Add a new database"
diff -r 8d2b705a5a51 -r eb531146be0e src/proto.h
--- a/src/proto.h Fri Jul 22 21:54:43 2005 +0000
+++ b/src/proto.h Sat Jul 23 22:25:46 2005 +0000
@@ -92,6 +92,7 @@
9292 # ifdef FEAT_HANGULIN
9393 # include "hangulin.pro"
9494 # endif
95+# include "hardcopy.pro"
9596 # include "hashtable.pro"
9697 # include "main.pro"
9798 # include "mark.pro"
diff -r 8d2b705a5a51 -r eb531146be0e src/proto/ex_cmds2.pro
--- a/src/proto/ex_cmds2.pro Fri Jul 22 21:54:43 2005 +0000
+++ b/src/proto/ex_cmds2.pro Sat Jul 23 22:25:46 2005 +0000
@@ -75,23 +75,6 @@
7575 void do_finish __ARGS((exarg_T *eap, int reanimate));
7676 int source_finished __ARGS((char_u *(*getline)(int, void *, int), void *cookie));
7777 void ex_checktime __ARGS((exarg_T *eap));
78-int get_printer_page_num __ARGS((void));
79-int prt_header_height __ARGS((void));
80-int prt_use_number __ARGS((void));
81-int prt_get_unit __ARGS((int idx));
82-void ex_hardcopy __ARGS((exarg_T *eap));
83-void mch_print_cleanup __ARGS((void));
84-int mch_print_init __ARGS((prt_settings_T *psettings, char_u *jobname, int forceit));
85-int mch_print_begin __ARGS((prt_settings_T *psettings));
86-void mch_print_end __ARGS((prt_settings_T *psettings));
87-int mch_print_end_page __ARGS((void));
88-int mch_print_begin_page __ARGS((char_u *str));
89-int mch_print_blank_page __ARGS((void));
90-void mch_print_start_line __ARGS((int margin, int page_line));
91-int mch_print_text_out __ARGS((char_u *p, int len));
92-void mch_print_set_font __ARGS((int iBold, int iItalic, int iUnderline));
93-void mch_print_set_bg __ARGS((long_u bgcol));
94-void mch_print_set_fg __ARGS((long_u fgcol));
9578 char_u *get_mess_lang __ARGS((void));
9679 void set_lang_var __ARGS((void));
9780 void ex_language __ARGS((exarg_T *eap));
diff -r 8d2b705a5a51 -r eb531146be0e src/proto/misc2.pro
--- a/src/proto/misc2.pro Fri Jul 22 21:54:43 2005 +0000
+++ b/src/proto/misc2.pro Sat Jul 23 22:25:46 2005 +0000
@@ -93,7 +93,6 @@
9393 int get_user_name __ARGS((char_u *buf, int len));
9494 void sort_strings __ARGS((char_u **files, int count));
9595 int pathcmp __ARGS((const char *p, const char *q, int maxlen));
96-char_u *parse_list_options __ARGS((char_u *option_str, option_table_T *table, int table_size));
9796 int filewritable __ARGS((char_u *fname));
9897 int emsg3 __ARGS((char_u *s, char_u *a1, char_u *a2));
9998 int emsgn __ARGS((char_u *s, long n));
diff -r 8d2b705a5a51 -r eb531146be0e src/version.h
--- a/src/version.h Fri Jul 22 21:54:43 2005 +0000
+++ b/src/version.h Sat Jul 23 22:25:46 2005 +0000
@@ -36,5 +36,5 @@
3636 #define VIM_VERSION_NODOT "vim70aa"
3737 #define VIM_VERSION_SHORT "7.0aa"
3838 #define VIM_VERSION_MEDIUM "7.0aa ALPHA"
39-#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 22)"
40-#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 22, compiled "
39+#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 23)"
40+#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Jul 23, compiled "
Show on old repository browser