# HG changeset patch # User vimboss # Date 1089452854 0 # Node ID 631143ac4a01c32e465380ba2ab7f82949f20d75 # Parent 946da5994c018f0cd1d7261cc7261634f87ee5ab updated for version 7.0007 diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -71,6 +71,7 @@ DOCS = \ pi_gzip.txt \ pi_netrw.txt \ pi_spec.txt \ + print.txt \ quickfix.txt \ quickref.txt \ quotes.txt \ @@ -126,6 +127,7 @@ DOCS = \ version4.txt \ version5.txt \ version6.txt \ + version7.txt \ vi_diff.txt \ visual.txt \ windows.txt \ @@ -189,6 +191,7 @@ HTMLS = \ pi_gzip.html \ pi_netrw.html \ pi_spec.html \ + print.html \ quickfix.html \ quickref.html \ quotes.html \ @@ -245,6 +248,7 @@ HTMLS = \ version4.html \ version5.html \ version6.html \ + version7.html \ vi_diff.html \ visual.html \ windows.html \ diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -928,6 +928,8 @@ system( {expr}) String output of shell tempname() String name for a temporary file tolower( {expr}) String the String {expr} switched to lowercase toupper( {expr}) String the String {expr} switched to uppercase +tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} + to chars in {tostr} type( {name}) Number type of variable {name} virtcol( {expr}) Number screen column of cursor or mark visualmode( [expr]) String last visual mode used @@ -2608,6 +2610,20 @@ toupper({expr}) *toupper()* characters turned into uppercase (just like applying |gU| to the string). +tr({src}, {fromstr}, {tostr}) *tr()* + The result is a copy of the {src} string with all characters + which appear in {fromstr} replaced by the character in that + position in the {tostr} string. Thus the first character in + {fromstr} is translated into the first character in {tostr} + and so on. Exactly like the unix "tr" command. + This code also deals with multibyte characters properly. + + Examples: > + echo tr("hello there", "ht", "HT") +< returns "Hello THere" > + echo tr("", "<>", "{}") +< returns "{blob}" + type({expr}) *type()* The result is a Number: 0 if {expr} has the type Number diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -129,6 +129,7 @@ Advanced editing ~ |fold.txt| hide (fold) ranges of lines Special issues ~ +|print.txt| printing |remote.txt| using Vim as a server or client |term.txt| using different terminals and mice |digraph.txt| list of available digraphs diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt --- a/runtime/doc/indent.txt +++ b/runtime/doc/indent.txt @@ -1,4 +1,4 @@ -*indent.txt* For Vim version 7.0aa. Last change: 2004 Apr 25 +*indent.txt* For Vim version 7.0aa. Last change: 2004 Jul 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -425,8 +425,8 @@ assume a 'shiftwidth' of 4. The defaults, spelled out in full, are: - cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,gs,hs,ps,ts,+s,c3,C0,(2s,us, - \U0,w0,m0,j0,)20,*30 + cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0, + /0,(2s,us,U0,w0,W0,m0,j0,)20,*30 Vim puts a line in column 1 if: - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 7.0aa. Last change: 2004 Jul 04 +*index.txt* For Vim version 7.0aa. Last change: 2004 Jul 07 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1224,6 +1224,8 @@ The commands are sorted on the non-optio |:mkvimrc| :mkv[imrc] write current mappings and settings to a file |:mkview| :mkvie[w] write view of current window to a file |:mode| :mod[e] show or change the screen mode +|:mzscheme| :mz[scheme] execute MzScheme command +|:mzfile| :mzf[ile] execute MzScheme script file |:next| :n[ext] go to next file in the argument list |:new| :new create a new empty window |:nmap| :nm[ap] like ":map" but for Normal mode diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt --- a/runtime/doc/mbyte.txt +++ b/runtime/doc/mbyte.txt @@ -1,4 +1,4 @@ -*mbyte.txt* For Vim version 7.0aa. Last change: 2004 Jun 16 +*mbyte.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 VIM REFERENCE MANUAL by Bram Moolenaar et al. @@ -742,6 +742,8 @@ is suitable for complex input, such as C Traditional and Simplified Chinese characters. And it can accept other locale if you make a correct input table. Xcin can be found at: http://xcin.linux.org.tw/ + Others are scim: http://scim.freedesktop.org/ and fcitx: + http://www.fcitx.org/ - Conversion Server *conversion-server* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4511,52 +4511,17 @@ A jump table for the options with a shor {not in Vi} {only available when compiled with the |+printer| feature} - This defines the name of the printer to be used when the |:hardcopy| - command is issued with a bang (!) to skip the printer selection - dialog. On Win32, it should be the printer name exactly as it appears - in the standard printer dialog. - If the option is empty, then vim will use the system default printer - for ":hardcopy!" - - *'printencoding'* *'penc'* *E620* -'printencoding' 'penc' String (default empty, except for: - Windows, OS/2: cp1252, - Macintosh: mac-roman, - VMS: dec-mcs, - HPUX: hp-roman8, - EBCDIC: ebcdic-uk) + The name of the printer to be used for |:hardcopy|. + See |pdev-option|. + + *'printencoding'* *'penc'* +'printencoding' 'penc' String (default empty, except for some systems) global {not in Vi} {only available when compiled with the |+printer| and |+postscript| features} - Sets the character encoding used when printing. This option tells VIM - which print character encoding file from the "print" directory in - 'runtimepath' to use. - - This option will accept any value from |encoding-names|. Any - recognized names are converted to VIM standard names - see 'encoding' - for more details. Names not recognized by VIM will just be converted - to lower case and underscores replaced with '-' signs. - - If 'printencoding' is empty or VIM cannot find the file then it will - use 'encoding' (if VIM is compiled with |+multi_byte| and it is set an - 8-bit encoding) to find the print character encoding file. If VIM is - unable to find a character encoding file then it will use the "latin1" - print character encoding file. - - When 'encoding' is set to a multi-byte encoding, VIM will try to - convert characters to the printing encoding for printing (if - 'printencoding' is empty then the conversion will be to latin1). - Conversion to a printing encoding other than latin1 will require VIM - to be compiled with the |+iconv| feature. If no conversion is - possible then printing will fail. Any characters that cannot be - converted will be replaced with upside down question marks. - - Four print character encoding files are provided to support default - Mac, VMS, HPUX, and EBCDIC character encodings and are used by default - on these platforms. Code page 1252 print character encoding is used - by default on Windows and OS/2 platforms. - + Sets the character encoding used when printing. + See |penc-option|. *'printexpr'* *'pexpr'* 'printexpr' 'pexpr' String (default: see below) @@ -4564,69 +4529,17 @@ A jump table for the options with a shor {not in Vi} {only available when compiled with the |+printer| and |+postscript| features} - Expression that is evaluated to print the PostScript produced with - ":hardcopy". - The file name to be printed is in |v:fname_in|. - The arguments to the ":hardcopy" command are in |v:cmdarg|. - The expression must take care of deleting the file after printing it. - When there is an error, the expression must return a non-zero number. - If there is no error, return zero or an empty string. - The default for non MS-Windows or VMS systems is to simply use "lpr" - to print the file: > - - system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) - . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error -< - On MS-Dos, MS-Windows and OS/2 machines the default is to copy the - file to the currently specified printdevice: > - - system('copy' . ' ' . v:fname_in . (&printdevice == '' - ? ' LPT1:' : (' \"' . &printdevice . '\"'))) - . delete(v:fname_in) -< - On VMS machines the default is to send the file to either the default - or currently specified printdevice: > - - system('print' . (&printdevice == '' ? '' : ' /queue=' . - &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) -< - If you change this option, using a function is an easy way to avoid - having to escape all the spaces. Example: > - - :set printexpr=PrintFile(v:fname_in) - :function PrintFile(fname) - : call system("ghostview " . a:fname) - : call delete(a:fname) - : return v:shell_error - :endfunc - -< Be aware that some print programs return control before they have read - the file. If you delete the file too soon it will not be printed. - These programs usually offer an option to have them remove the file - when printing is done. - *E365* - If evaluating the expression fails or it results in a non-zero number, - you get an error message. In that case Vim will delete the - file. In the default value for non-MS-Windows a trick is used: Adding - "v:shell_error" will result in a non-zero number when the system() - call fails. - This option cannot be set from a |modeline| or in the |sandbox|, for - security reasons. - - *'printfont'* *'pfn'* *E613* + Expression used to print the PostScript produced with |:hardcopy|. + See |pexpr-option|. + + *'printfont'* *'pfn'* 'printfont' 'pfn' string (default "courier") global {not in Vi} {only available when compiled with the |+printer| feature} - This is the name of the font that will be used for the |:hardcopy| - command's output. It has the same format as the 'guifont' option, - except that only one font may be named, and the special "guifont=*" - syntax is not available. - In the Win32 GUI version this specifies a font name with its extra - attributes, as with the 'guifont' option. - For other systems, only ":h11" is recognized, where "11" is the point - size of the font. When omitted, the point size is 10. + The name of the font that will be used for |:hardcopy|. + See |pfn-option|. *'printheader'* *'pheader'* 'printheader' 'pheader' string (default "%<%f%h%m%=Page %N") @@ -4634,100 +4547,35 @@ A jump table for the options with a shor {not in Vi} {only available when compiled with the |+printer| feature} - This defines the format of the header produced in |:hardcopy| output. - The option is defined in the same way as the 'statusline' option. - If Vim has not been compiled with the |+statusline| feature, this - option has no effect and a simple default header is used, which shows - the page number. + The format of the header produced in |:hardcopy| output. + See |pheader-option|. + + *'printmbcharset'* *'pmbcs'* +'printmbcharset' 'pmbcs' string (default "") + global + {not in Vi} + {only available when compiled with the |+printer| + and |+multi_byte| features} + The CJK character set to be used for CJK output from |:hardcopy|. + See |pmbcs-option|. + + *'printmbfont'* *'pmbfn'* +'printmbfont' 'pmbfn' string (default "") + global + {not in Vi} + {only available when compiled with the |+printer| + and |+multi_byte| features} + List of font names to be used for CJK output from |:hardcopy|. + See |pmbfn-option|. *'printoptions'* *'popt'* 'printoptions' 'popt' string (default "") global {not in Vi} {only available when compiled with |+printer| feature} - This is a comma-separated list of items that control the format of - the output of |:hardcopy|: - - left:{spec} left margin (default: 10pc) - right:{spec} right margin (default: 5pc) - top:{spec} top margin (default: 5pc) - bottom:{spec} bottom margin (default: 5pc) - {spec} is a number followed by "in" for - inches, "pt" for points (1 point is 1/72 of an - inch), "mm" for millimeters or "pc" for a - percentage of the media size. - Weird example: - left:2in,top:30pt,right:16mm,bottom:3pc - If the unit is not recognized there is no - error and the default value is used. - - header:{nr} Number of lines to reserve for the header. - Only the first line is actually filled, thus - when {nr} is 2 there is one empty line. The - header is formatted according to - 'printheader'. - header:0 Do not print a header. - header:2 (default) Use two lines for the header - - syntax:n Do not use syntax highlighting. This is - faster and thus useful when printing large - files. - syntax:y Do syntax highlighting. - syntax:a (default) Use syntax highlighting if the printer appears - to be able to print color or grey. - - number:y Include line numbers in the printed output. - number:n (default) No line numbers. - - wrap:y (default) Wrap long lines. - wrap:n Truncate long lines. - - duplex:off Print on one side. - duplex:long (default) Print on both sides (when possible), bind on - long side. - duplex:short Print on both sides (when possible), bind on - short side. - - collate:y (default) Collating: 1 2 3, 1 2 3, 1 2 3 - collate:n No collating: 1 1 1, 2 2 2, 3 3 3 - - jobsplit:n (default) Do all copies in one print job - jobsplit:y Do each copy as a separate print job. Useful - when doing N-up postprocessing. - - portrait:y (default) Orientation is portrait. - portrait:n Orientation is landscape. - *a4* *letter* - paper:A4 (default) Paper size: A4 - paper:{name} Paper size from this table: - {name} size in cm size in inch ~ - 10x14 25.4 x 35.57 10 x 14 - A3 29.7 x 42 11.69 x 16.54 - A4 21 x 29.7 8.27 x 11.69 - A5 14.8 x 21 5.83 x 8.27 - B4 25 x 35.3 10.12 x 14.33 - B5 17.6 x 25 7.17 x 10.12 - executive 18.42 x 26.67 7.25 x 10.5 - folio 21 x 33 8.27 x 13 - ledger 43.13 x 27.96 17 x 11 - legal 21.59 x 35.57 8.5 x 14 - letter 21.59 x 27.96 8.5 x 11 - quarto 21.59 x 27.5 8.5 x 10.83 - statement 13.97 x 21.59 5.5 x 8.5 - tabloid 27.96 x 43.13 11 x 17 - - formfeed:n (default) Treat form feed characters (0x0c) as a normal - print character. - formfeed:y When a form feed character is encountered, - continue printing of the current line at the - beginning of the first line on a new page. - - The item indicated with (default) is used when the item is not - present. The values are not always used, especially when using a - dialog to select the printer and options. - Example: > - :set printoptions=paper:letter,duplex:off -< + List of items that control the format of the output of |:hardcopy|. + See |popt-option|. + *'quoteescape''* *'qe'* 'quoteescape' 'qe' string (default "\") local to buffer diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -17,20 +17,6 @@ 4. Transparent File Transfer........... 5. Ex Commands.........................................|netrw-ex| 6. Variables and Options...............................|netrw-var| 7. Remote Directory Browser............................|netrw-browse| - ?..........Help....................................|netrw-help| - .......Browsing................................|netrw-cr| - ......Refreshing the Listing..................|netrw-c-l| - ......Removing Files or Directories...........|netrw-delete| - D..........Removing Files or Directories...........|netrw-D| - R..........Renaming Files or Directories...........|netrw-R| - -..........Going Up................................|netrw--| - a..........Hiding Files or Directories.............|netrw-a| - h..........Edit File/Directory Hiding..............|netrw-h| - o..........Browsing with a Horizontal Split........|netrw-o| - r..........Reversing Sorting Order.................|netrw-r| - s..........Selecting Sorting Style.................|netrw-s| - v..........Browsing with a Vertical Split..........|netrw-v| - x..........Customizing Browsing....................|netrw-x| 8. Debugging...........................................|netrw-debug| 9. History.............................................|netrw-history| 10. Credits.............................................|netrw-credits| @@ -514,7 +500,26 @@ from itself: ============================================================================== 7. Remote Directory Browser *netrw-browse* *netrw-dir* *netrw-list* *netrw-help* + ?..........Help....................................|netrw-help| + .......Browsing................................|netrw-cr| + ......Refreshing the Listing..................|netrw-c-l| + ......Removing Files or Directories...........|netrw-delete| + D..........Removing Files or Directories...........|netrw-D| + \H.........Edit File/Directory Hiding List.........|netrw-H| + \M.........Make A New Directory....................|netrw-M| + R..........Renaming Files or Directories...........|netrw-R| + -..........Going Up................................|netrw--| + a..........Hiding Files or Directories.............|netrw-a| + i..........Long Listing............................|netrw-i| + o..........Browsing with a Horizontal Split........|netrw-o| + r..........Reversing Sorting Order.................|netrw-r| + s..........Selecting Sorting Style.................|netrw-s| + v..........Browsing with a Vertical Split..........|netrw-v| + x..........Customizing Browsing....................|netrw-x| + *netrw-browse-cmds* > + Quick Reference Commands Table + ------- ----------- Command Explanation ------- ----------- ? Causes Netrw to issue help @@ -526,6 +531,7 @@ 7. Remote Directory Browser *netrw-brows - Makes Netrw go up one directory a Show all of a directory (temporarily ignore g:netrw_list_hide) h Edit file hiding list + i Toggles between long and short listing o Enter the file/directory under the cursor in a new browser window. A horizontal split is used. r Reverse sorting order @@ -540,16 +546,22 @@ 7. Remote Directory Browser *netrw-brows Var Explanation --- ----------- g:netrw_list_cmd supports listing - g:netrw_rm_cmd supports removing files - g:netrw_rmf_cmd supports removing softlinks to directories - g:netrw_rmdir_cmd supports removing directories - g:netrw_winsize specify initial size of new o/v windows g:netrw_list_hide comma separated list of patterns for hiding files + g:netrw_local_mkdir specify command for making a directory locally + g:netrw_local_rmdir remove directory command default: rmdir + g:netrw_local_rename rename file/directory command + unix-default: rm win32-default: ren + g:netrw_mkdir_cmd specify command for making a directory remotely + g:netrw_rm_cmd supports removing files + g:netrw_rmdir_cmd supports removing directories + g:netrw_rmf_cmd supports removing softlinks to directories g:netrw_sort_by sort by "name", "time", or "size" g:netrw_sort_direction sorting direction: "normal" or "reverse" g:netrw_sort_sequence when sorting by name, first sort by the comma-separated pattern sequence + g:netrw_timefmt specify format string to strftime() default: %c + g:netrw_winsize specify initial size of new o/v windows < INTRODUCTION TO REMOTE DIRECTORY BROWSING @@ -588,15 +600,33 @@ preferred. The NetList function which i browsing expects that directories will be flagged by a trailing slash. -BROWSING *netrw-cr* +BROWSING *netrw-cr* Browsing is simple: move the cursor onto a file or directory of interest. Hitting the (the return key) will select the file or directory. Directories will themselves be listed, and files will be opened using the protocol given in the original read request. +LONG VS SHORT LISTING *netrw-i* -REMOVING FILES OR DIRECTORIES *netrw-delete* *netrw-remove* *netrw-D* +The short listing format gives just the files' and directories' names. +The long listing is either based on the "ls" command via ssh for remote +directories or displays the filename, file size (in bytes), and the +time and date of last modification for local directories. + + +MAKING A NEW DIRECTORY *netrw-M* + +Actually M, where the is, by default, the backslash. + +With the "M" map one may make a new directory either remotely (which +depends on the global variable g:netrw_mkdir_cmd) or locally (which depends on +the global variable g:netrw_local_mkdir). Netrw will issue a request for the +new directory's name. A bare at that point will abort the making of the +directory. Attempts to make a local directory that already exists (as either +a file or a directory) will be detected, reported on, and ignored. + +REMOVING FILES OR DIRECTORIES *netrw-delete* *netrw-remove* *netrw-D* Deleting/removing files and directories involves moving the cursor to the file/directory to be deleted and pressing "D". Directories must be empty first @@ -626,7 +656,7 @@ to remove it again using the g:netrw_rmf g:netrw_rmf_cmd: ssh HOSTNAME rm -f -RENAMING FILES OR DIRECTORIES *netrw-move* *netrw-rename* +RENAMING FILES OR DIRECTORIES *netrw-move* *netrw-rename* *netrw-R* Renaming/moving files and directories involves moving the cursor to the file/directory to be moved (renamed) and pressing "R". You will then be @@ -643,13 +673,18 @@ HIDING FILES OR DIRECTORIES *g:netrw_a* The "a" map lets the browser ignore the g:netrw_list_hide variable. Normally the g:netrw_list_hide variable holds a comma separated list of patterns which -will be hidden (removed) from the directory listing. +will be hidden (removed) from the directory listing. Mnemonically, the +"a" stands for show All. -EDIT FILE OR DIRECTORY HIDING *netrw-h* +EDIT FILE OR DIRECTORY HIDING LIST *netrw-H* + +Actually H, where the is, by default, the backslash. -The "h" map brings up a requestor allowing the user to change the -file/directory hiding list. +The "H" map brings up a requestor allowing the user to change the +file/directory hiding list. The hiding list consists of one or more +patterns delimited by commas. Files and/or directories satisfying +these patterns will be hidden (ie. not shown). BROWSING WITH A HORIZONTALLY SPLIT WINDOW *netrw-o* diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt new file mode 100644 --- /dev/null +++ b/runtime/doc/print.txt @@ -0,0 +1,751 @@ +*print.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +Printing *printing* + +1. Introduction |print-intro| +2. Print options |print-options| +3. PostScript Printing |postscript-printing| +4. PostScript Printing Encoding |postscript-print-encoding| +5. PostScript CJK Printing |postscript-cjk-printing| +6. PostScript Printing Troubleshooting |postscript-print-trouble| +7. PostScript Utilities |postscript-print-util| +8. Formfeed Characters |printing-formfeed| + +{Vi has None of this} +{only available when compiled with the |+printer| feature} + +============================================================================== +1. Introduction *print-intro* + +On MS-Windows Vim can print your text on any installed printer. On other +systems a PostScript file is produced. This can be directly sent to a +PostScript printer. For other printers a program like ghostscript needs to be +used. + + *:ha* *:hardcopy* *E237* *E238* *E324* +:[range]ha[rdcopy][!] [arguments] + Send [range] lines (default whole file) to the + printer. + + On MS-Windows a dialog is displayed to allow selection + of printer, paper size etc. To skip the dialog, use + the [!]. In this case the printer defined by + 'printdevice' is used, or, if 'printdevice' is empty, + the system default printer. + + For systems other than MS-Windows, PostScript is + written in a temp file and 'printexpr' is used to + actually print it. Then [arguments] can be used by + 'printexpr' through |v:cmdarg|. Otherwise [arguments] + is ignored. 'printoptions' can be used to specify + paper size, duplex, etc. + +:[range]ha[rdcopy][!] >{filename} + As above, but write the resulting PostScript in file + {filename}. + Things like "%" are expanded |cmdline-special| + Careful: An existing file is silently overwritten. + {only available when compiled with the |+postscript| + feature} + On MS-Windows use the "print to file" feature of the + printer driver. + +Progress is displayed during printing as a page number and a percentage. To +abort printing use the interrupt key (CTRL-C or, on MS-systems, CTRL-Break). + +Printer output is controlled by the 'printfont' and 'printoptions' options. +'printheader' specifies the format of a page header. + +The printed file is always limited to the selected margins, irrespective of +the current window's 'wrap' or 'linebreak' settings. The "wrap" item in +'printoptions' can be used to switch wrapping off. +The current highlighting colors are used in the printout, with the following +considerations: +1) The normal background is always rendered as white (i.e. blank paper.) +2) White text or the default foreground is rendered as black, so that it shows + up! +3) If 'background' is "dark", then the colours are darkened to compensate for + the fact that otherwise they would be too bright to show up clearly on + white paper. + +============================================================================== +2. Print options *print-options* + +Here are the details for the options that change the way printing is done. +For generic info about setting options see |options.txt|. + + *pdev-option* +'printdevice' 'pdev' string (default empty) + global +This defines the name of the printer to be used when the |:hardcopy| command +is issued with a bang (!) to skip the printer selection dialog. On Win32, it +should be the printer name exactly as it appears in the standard printer +dialog. +If the option is empty, then vim will use the system default printer for +":hardcopy!" + + *penc-option* *E620* +'printencoding' 'penc' String (default empty, except for: + Windows, OS/2: cp1252, + Macintosh: mac-roman, + VMS: dec-mcs, + HPUX: hp-roman8, + EBCDIC: ebcdic-uk) + global +Sets the character encoding used when printing. This option tells VIM which +print character encoding file from the "print" directory in 'runtimepath' to +use. + +This option will accept any value from |encoding-names|. Any recognized names +are converted to VIM standard names - see 'encoding' for more details. Names +not recognized by VIM will just be converted to lower case and underscores +replaced with '-' signs. + +If 'printencoding' is empty or VIM cannot find the file then it will use +'encoding' (if VIM is compiled with |+multi_byte| and it is set an 8-bit +encoding) to find the print character encoding file. If VIM is unable to find +a character encoding file then it will use the "latin1" print character +encoding file. + +When 'encoding' is set to a multi-byte encoding, VIM will try to convert +characters to the printing encoding for printing (if 'printencoding' is empty +then the conversion will be to latin1). Conversion to a printing encoding +other than latin1 will require VIM to be compiled with the |+iconv| feature. +If no conversion is possible then printing will fail. Any characters that +cannot be converted will be replaced with upside down question marks. + +Four print character encoding files are provided to support default Mac, VMS, +HPUX, and EBCDIC character encodings and are used by default on these +platforms. Code page 1252 print character encoding is used by default on +Windows and OS/2 platforms. + + *pexpr-option* +'printexpr' 'pexpr' String (default: see below) + global +Expression that is evaluated to print the PostScript produced with +|:hardcopy|. +The file name to be printed is in |v:fname_in|. +The arguments to the ":hardcopy" command are in |v:cmdarg|. +The expression must take care of deleting the file after printing it. +When there is an error, the expression must return a non-zero number. +If there is no error, return zero or an empty string. +The default for non MS-Windows or VMS systems is to simply use "lpr" to print +the file: > + + system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) + . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error + +On MS-Dos, MS-Windows and OS/2 machines the default is to copy the file to the +currently specified printdevice: > + + system('copy' . ' ' . v:fname_in . (&printdevice == '' + ? ' LPT1:' : (' \"' . &printdevice . '\"'))) + . delete(v:fname_in) + +On VMS machines the default is to send the file to either the default or +currently specified printdevice: > + + system('print' . (&printdevice == '' ? '' : ' /queue=' . + &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + +If you change this option, using a function is an easy way to avoid having to +escape all the spaces. Example: > + + :set printexpr=PrintFile(v:fname_in) + :function PrintFile(fname) + : call system("ghostview " . a:fname) + : call delete(a:fname) + : return v:shell_error + :endfunc + +Be aware that some print programs return control before they have read the +file. If you delete the file too soon it will not be printed. These programs +usually offer an option to have them remove the file when printing is done. + *E365* +If evaluating the expression fails or it results in a non-zero number, you get +an error message. In that case Vim will delete the file. In the default +value for non-MS-Windows a trick is used: Adding "v:shell_error" will result +in a non-zero number when the system() call fails. + +This option cannot be set from a |modeline| or in the |sandbox|, for security +reasons. + + *pfn-option* *E613* +'printfont' 'pfn' string (default "courier") + global +This is the name of the font that will be used for the |:hardcopy| command's +output. It has the same format as the 'guifont' option, except that only one +font may be named, and the special "guifont=*" syntax is not available. + +In the Win32 GUI version this specifies a font name with its extra attributes, +as with the 'guifont' option. + +For other systems, only ":h11" is recognized, where "11" is the point size of +the font. When omitted, the point size is 10. + + *pheader-option* +'printheader' 'pheader' string (default "%<%f%h%m%=Page %N") + global +This defines the format of the header produced in |:hardcopy| output. The +option is defined in the same way as the 'statusline' option. If Vim has not +been compiled with the |+statusline| feature, this option has no effect and a +simple default header is used, which shows the page number. + + *pmbcs-option* +'printmbcharset' 'pmbcs' string (default "") + global +Sets the CJK character set to be used when generating CJK output from +|:hardcopy|. The following predefined values are currently recognised by VIM: + + Value Description ~ + Chinese GB_2312-80 + (Simplified) GBT_12345-90 + MAC Apple Mac Simplified Chinese + GBT-90_MAC GB/T 12345-90 Apple Mac Simplified + Chinese + GBK GBK (GB 13000.1-93) + ISO10646 ISO 10646-1:1993 + + Chinese CNS_1993 CNS 11643-1993, Planes 1 & 2 + (Traditional) BIG5 + ETEN Big5 with ETen extensions + ISO10646 ISO 10646-1:1993 + + Japanese JIS_C_1978 + JIS_X_1983 + JIS_X_1990 + MSWINDOWS Win3.1/95J (JIS X 1997 + NEC + + IBM extensions) + KANJITALK6 Apple Mac KanjiTalk V6.x + KANJITALK7 Apple Mac KanjiTalk V7.x + + Korean KS_X_1992 + MAC Apple Macintosh Korean + MSWINDOWS KS X 1992 with MS extensions + ISO10646 ISO 10646-1:1993 + +Only certain combinations of the above values and 'printencoding' are +possible. The following tables show the valid combinations: + + euc-cn gbk ucs-2 utf-8 ~ + Chinese GB_2312-80 x + (Simplified) GBT_12345-90 x + MAC x + GBT-90_MAC x + GBK x + ISO10646 x x + + euc-tw big5 ucs-2 utf-8 ~ + Chinese CNS_1993 x + (Traditional) BIG5 x + ETEN x + ISO10646 x x + + euc-jp sjis ucs-2 utf-8 ~ + Japanese JIS_C_1978 x x + JIS_X_1983 x x + JIS_X_1990 x x x + MSWINDOWS x + KANJITALK6 x + KANJITALK7 x + + euc-kr cp949 ucs-2 utf-8 ~ + Korean KS_X_1992 x + MAC x + MSWINDOWS x + ISO10646 x x + +To set up the correct encoding and character set for printing some +Japanese text you would do the following; > + :set printencoding=euc-jp + :set printmbcharset=JIS_X_1983 + +If 'printmbcharset' is not one of the above values then it is assumed to +specify a custom multi-byte character set and no check will be made that it is +compatible with the value for 'printencoding'. VIM will look for a file +defining the character set in the "print" directory in 'runtimepath'. + + *pmbfn-option* +'printmbfont' 'pmbfn' string (default "") + global +This is a comma-separated list of fields for font names to be used when +generating CJK output from |:hardcopy|. Each font name has to be preceded +with a letter indicating the style the font is to be used for as follows: + + r:{font-name} font to use for normal characters + b:{font-name} font to use for bold characters + i:{font-name} font to use for italic characters + o:{font-name} font to use for bold-italic characters + +A field with the r: prefix must be specified when doing CJK printing. The +other fontname specifiers are optional. If a specifier is missing then +another font will be used as follows: + + if b: is missing, then use r: + if i: is missing, then use r: + if o: is missing, then use i: + +Some CJK fonts do not contain characters for codes in the ASCII code range. +Also, some characters in the CJK ASCII code ranges differ in a few code points +from traditional ASCII characters. There are two additional fields to control +printing of characters in the ASCII code range. + + c:yes Use Courier font for characters in the ASCII + c:no (default) code range. + + a:yes Use ASCII character set for codes in the ASCII + a:no (default) code range. + +The following is an example of specifying two multi-byte fonts, one for normal +and italic printing and one for bold and bold-italic printing, and using +Courier to print codes in the ASCII code range but using the national +character set: > + :set printmbfont=r:WadaMin-Regular,b:WadaMin-Bold,c:yes +< + *popt-option* +'printoptions' 'popt' string (default "") + global +This is a comma-separated list of items that control the format of the output +of |:hardcopy|: + + left:{spec} left margin (default: 10pc) + right:{spec} right margin (default: 5pc) + top:{spec} top margin (default: 5pc) + bottom:{spec} bottom margin (default: 5pc) + {spec} is a number followed by "in" for inches, "pt" + for points (1 point is 1/72 of an inch), "mm" for + millimeters or "pc" for a percentage of the media + size. + Weird example: + left:2in,top:30pt,right:16mm,bottom:3pc + If the unit is not recognized there is no error and + the default value is used. + + header:{nr} Number of lines to reserve for the header. + Only the first line is actually filled, thus when {nr} + is 2 there is one empty line. The header is formatted + according to 'printheader'. + header:0 Do not print a header. + header:2 (default) Use two lines for the header + + syntax:n Do not use syntax highlighting. This is faster and + thus useful when printing large files. + syntax:y Do syntax highlighting. + syntax:a (default) Use syntax highlighting if the printer appears to be + able to print color or grey. + + number:y Include line numbers in the printed output. + number:n (default) No line numbers. + + wrap:y (default) Wrap long lines. + wrap:n Truncate long lines. + + duplex:off Print on one side. + duplex:long (default) Print on both sides (when possible), bind on long + side. + duplex:short Print on both sides (when possible), bind on short + side. + + collate:y (default) Collating: 1 2 3, 1 2 3, 1 2 3 + collate:n No collating: 1 1 1, 2 2 2, 3 3 3 + + jobsplit:n (default) Do all copies in one print job + jobsplit:y Do each copy as a separate print job. Useful when + doing N-up postprocessing. + + portrait:y (default) Orientation is portrait. + portrait:n Orientation is landscape. + *a4* *letter* + paper:A4 (default) Paper size: A4 + paper:{name} Paper size from this table: + {name} size in cm size in inch ~ + 10x14 25.4 x 35.57 10 x 14 + A3 29.7 x 42 11.69 x 16.54 + A4 21 x 29.7 8.27 x 11.69 + A5 14.8 x 21 5.83 x 8.27 + B4 25 x 35.3 10.12 x 14.33 + B5 17.6 x 25 7.17 x 10.12 + executive 18.42 x 26.67 7.25 x 10.5 + folio 21 x 33 8.27 x 13 + ledger 43.13 x 27.96 17 x 11 + legal 21.59 x 35.57 8.5 x 14 + letter 21.59 x 27.96 8.5 x 11 + quarto 21.59 x 27.5 8.5 x 10.83 + statement 13.97 x 21.59 5.5 x 8.5 + tabloid 27.96 x 43.13 11 x 17 + + formfeed:n (default) Treat form feed characters (0x0c) as a normal print + character. + formfeed:y When a form feed character is encountered, continue + printing of the current line at the beginning of the + first line on a new page. + +The item indicated with (default) is used when the item is not present. The +values are not always used, especially when using a dialog to select the +printer and options. +Example: > + :set printoptions=paper:letter,duplex:off + +============================================================================== +3. PostScript Printing *postscript-printing* + *E455* *E456* *E457* *E624* +Provided you have enough disk space there should be no problems generating a +PostScript file. You need to have the runtime files correctly installed (if +you can find the help files, they probably are). + +There are currently a number of limitations with PostScript printing: + +- 'printfont' - The font name is ignored (the Courier family is always used - + it should be available on all PostScript printers) but the font size is + used. + +- 'printoptions' - The duplex setting is used when generating PostScript + output, but it is up to the printer to take notice of the setting. If the + printer does not support duplex printing then it should be silently ignored. + Some printers, however, don't print at all. + +- 8-bit support - While a number of 8-bit print character encodings are + supported it is possible that some characters will not print. Whether a + character will print depends on the font in the printer knowing the + character. Missing characters will be replaced with an upside down question + mark, or a space if that character is also not known by the font. It may be + possible to get all the characters in an encoding to print by installing a + new version of the Courier font family. + +- Multi-byte support - Currently VIM will try to convert multi-byte characters + to the 8-bit encoding specified by 'printencoding' (or latin1 if it is + empty). Any characters that are not successfully converted are shown as + unknown characters. Printing will fail if VIM cannot convert the multi-byte + to the 8-bit encoding. + +============================================================================== +4. Custom 8-bit Print Character Encodings *postscript-print-encoding* + *E618* *E619* +To use your own print character encoding when printing 8-bit character data +you need to define your own PostScript font encoding vector. Details on how +to to define a font encoding vector is beyond the scope of this help file, but +you can find details in the PostScript Language Reference Manual, 3rd Edition, +published by Addison-Wesley and available in PDF form at +http://www.adobe.com/. The following describes what you need to do for VIM to +locate and use your print character encoding. + +i. Decide on a unique name for your encoding vector, one that does not clash + with any of the recognized or standard encoding names that VIM uses (see + |encoding-names| for a list), and that no one else is likely to use. +ii. Copy $VIMRUNTIME/print/latin1.ps to the print subdirectory in your + 'runtimepath' and rename it with your unique name. +iii. Edit your renamed copy of latin1.ps, replacing all occurrences of latin1 + with your unique name (don't forget the line starting %%Title:), and + modify the array of glyph names to define your new encoding vector. The + array must have exactly 256 entries or you will not be able to print! +iv. Within VIM, set 'printencoding' to your unique encoding name and then + print your file. VIM will now use your custom print character encoding. + +VIM will report an error with the resource file if you change the order or +content of the first 3 lines, other than the name of the encoding on the line +starting %%Title: or the version number on the line starting %%Version:. + +[Technical explanation for those that know PostScript - VIM looks for a file +with the same name as the encoding it will use when printing. The file +defines a new PostScript Encoding resource called /VIM-name, where name is the +print character encoding VIM will use.] + +============================================================================== +5. PostScript CJK Printing *postscript-cjk-printing* + *E673* *E674* *E675* + +VIM supports printing of Chinese, Japanese, and Korean files. Setting up VIM +to correctly print CJK files requires setting up a few more options. + +Each of these countries has many standard character sets and encodings which +require that both be specified when printing. In addition, CJK fonts normally +do not have the concept of italic glyphs and use different weight or stroke +style to achieve emphasis when printing. This in turn requires a different +approach to specifying fonts to use when printing. + +The encoding and character set are specified with the 'printencoding' and +'printmbcharset' options. If 'printencoding' is not specified then 'encoding' +is used as normal. If 'printencoding' is specified then characters will be +translated to this encoding for printing. You should ensure that the encoding +is compatible with the character set needed for the file contents or some +characters may not appear when printed. + +The fonts to use for CJK printing are specified with 'printmbfont'. This +option allows you to specify different fonts to use when printing characters +which are syntax highlighted with the font styles normal, italic, bold and +bold-italic. + +No CJK fonts are supplied with VIM. There are some free Korean, Japanese, and +Traditional Chinese fonts available at: + + http://examples.oreilly.com/cjkvinfo/adobe/samples/ + +You can find descriptions of the various fonts in the read me file at + + http://examples.oreilly.com/cjkvinfo/adobe/00README + +Please read your printer documentation on how to install new fonts. + +CJK fonts can be large containing several thousand glyphs, and it is not +uncommon to find that they only contain a subset of a national standard. It +is not unusual to find the fonts to not include characters for codes in the +ASCII code range. If you find half-width Roman characters are not appearing +in your printout then you should configure VIM to use the Courier font the +half-width ASCII characters with 'printmbfont'. If your font does not include +other characters then you will need to find another font that does. + +Another issue with ASCII characters, is that the various national character +sets specify a couple of different glyphs in the ASCII code range. If you +print ASCII text using the national character set you may see some unexpected +characters. If you want true ASCII code printing then you need to configure +VIM to output ASCII characters for the ASCII code range with 'printmbfont'. + +It is possible to define your own multi-byte character set although this +should not be attempted lightly. A discussion on the process if beyond the +scope of these help files. You can find details on CMap (character map) files +in the document 'Adobe CMap and CIDFont Files Specification, Version 1.0', +available from http://www.adobe.com as a PDF file. + +============================================================================== +6. PostScript Printing Troubleshooting *postscript-print-trouble* + *E621* +Usually the only sign of a problem when printing with PostScript is that your +printout does not appear. If you are lucky you may get a printed page that +tells you the PostScript operator that generated the error that prevented the +print job completing. + +There are a number of possible causes as to why the printing may have failed: + +- Wrong version of the prolog resource file. The prolog resource file + contains some PostScript that VIM needs to be able to print. Each version + of VIM needs one particular version. Make sure you have correctly installed + the runtime files, and don't have any old versions of a file called prolog + in the print directory in your 'runtimepath' directory. + +- Paper size. Some PostScript printers will abort printing a file if they do + not support the requested paper size. By default VIM uses A4 paper. Find + out what size paper your printer normally uses and set the appropriate paper + size with 'printoptions'. If you cannot find the name of the paper used, + measure a sheet and compare it with the table of supported paper sizes listed + for 'printoptions', using the paper that is closest in both width AND height. + Note: The dimensions of actual paper may vary slightly from the ones listed. + If there is no paper listed close enough, then you may want to try psresize + from PSUtils, discussed below. + +- Two-sided printing (duplex). Normally a PostScript printer that does not + support two-sided printing will ignore any request to do it. However, some + printers may abort the job altogether. Try printing with duplex turned off. + Note: Duplex prints can be achieved manually using PS utils - see below. + +- Collated printing. As with Duplex printing, most PostScript printers that + do not support collating printouts will ignore a request to do so. Some may + not. Try printing with collation turned off. + +- Syntax highlighting. Some print management code may prevent the generated + PostScript file from being printed on a black and white printer when syntax + highlighting is turned on, even if solid black is the only color used. Try + printing with syntax highlighting turned off. + +A safe printoptions setting to try is: > + + :set printoptions=paper:A4,duplex:off,collate:n,syntax:n + +Replace "A4" with the paper size that best matches your printer paper. + +============================================================================== +7. PostScript Utilities *postscript-print-util* + +7.1 Ghostscript + +Ghostscript is a PostScript and PDF interpreter that can be used to display +and print on non-PostScript printers PostScript and PDF files. It can also +generate PDF files from PostScript. + +Ghostscript will run on a wide variety of platforms. + +There are three available versions: + +- AFPL Ghostscript (formerly Aladdin Ghostscript) which is free for + non-commercial use. It can be obtained from: + + http://www.cs.wisc.edu/~ghost/ + +- GNU Ghostscript which is available under the GNU General Public License. It + can be obtained from: + + ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/gnu/ + +- A commercial version for inclusion in commercial products. + +Additional information on Ghostscript can also be found at: + + http://www.ghostscript.com/ + +Support for a number of non PostScript printers is provided in the +distribution as standard, but if you cannot find support for your printer +check the Ghostscript site for other printers not included by default. + + +7.2 Ghostscript Previewers. + +The interface to Ghostscript is very primitive so a number of graphical front +ends have been created. These allow easier PostScript file selection, +previewing at different zoom levels, and printing. Check supplied +documentation for full details. + +X11 + +- Ghostview. Obtainable from: + + http://www.cs.wisc.edu/~ghost/gv/ + +- gv. Derived from Ghostview. Obtainable from: + + http://wwwthep.physik.uni-mainz.de/~plass/gv/ + + Copies (possibly not the most recent) can be found at: + + http://www.cs.wisc.edu/~ghost/gv/ + +OpenVMS + +- Is apparently supported in the main code now (untested). See: + + http://wwwthep.physik.uni-mainz.de/~plass/gv/ + +Windows and OS/2 + +- GSview. Obtainable from: + + http://www.cs.wisc.edu/~ghost/gsview/ + +DOS + +- ps_view. Obtainable from: + + ftp://ftp.pg.gda.pl/pub/TeX/support/ps_view/ + ftp://ftp.dante.de/tex-archive/support/ps_view/ + +Linux + +- GSview. Linux version of the popular Windows and OS/2 previewer. + Obtainable from: + + http://www.cs.wisc.edu/~ghost/gsview/ + +- BMV. Different from Ghostview and gv in that it doesn't use X but svgalib. + Obtainable from: + + ftp://sunsite.unc.edu/pub/Linux/apps/graphics/viewers/svga/bmv-1.2.tgz + + +7.3 PSUtils + +PSUtils is a collection of utility programs for manipulating PostScript +documents. Binary distributions are available for many platforms, as well as +the full source. PSUtils can be found at: + + http://knackered.org/angus/psutils + +The utilities of interest include: + +- psnup. Convert PS files for N-up printing. +- psselect. Select page range and order of printing. +- psresize. Change the page size. +- psbook. Reorder and lay out pages ready for making a book. + +The output of one program can be used as the input to the next, allowing for +complex print document creation. + + +N-UP PRINTING + +The psnup utility takes an existing PostScript file generated from VIM and +convert it to an n-up version. The simplest way to create a 2-up printout is +to first create a PostScript file with: > + + :hardcopy > test.ps + +Then on your command line execute: > + + psnup -n 2 test.ps final.ps + +Note: You may get warnings from some Ghostscript previewers for files produced +by psnup - these may safely be ignored. + +Finally print the file final.ps to your PostScript printer with your +platform's print command. (You will need to delete the two PostScript files +afterwards yourself.) 'printexpr' could be modified to perform this extra +step before printing. + + +ALTERNATE DUPLEX PRINTING + +It is possible to achieve a poor man's version of duplex printing using the PS +utility psselect. This utility has options -e and -o for printing just the +even or odd pages of a PS file respectively. + +First generate a PS file with the 'hardcopy' command, then generate a new +files with all the odd and even numbered pages with: > + + psselect -o test.ps odd.ps + psselect -e test.ps even.ps + +Next print odd.ps with your platform's normal print command. Then take the +print output, turn it over and place it back in the paper feeder. Now print +even.ps with your platform's print command. All the even pages should now +appear on the back of the odd pages. + +There a couple of points to bear in mind: + +1. Position of the first page. If the first page is on top of the printout + when printing the odd pages then you need to reverse the order that the odd + pages are printed. This can be done with the -r option to psselect. This + will ensure page 2 is printed on the back of page 1. + Note: it is better to reverse the odd numbered pages rather than the even + numbered in case there are an odd number of pages in the original PS file. + +2. Paper flipping. When turning over the paper with the odd pages printed on + them you may have to either flip them horizontally (along the long edge) or + vertically (along the short edge), as well as possibly rotating them 180 + degrees. All this depends on the printer - it will be more obvious for + desktop ink jets than for small office laser printers where the paper path + is hidden from view. + + +============================================================================== +8. Formfeed Characters *printing-formfeed* + +By default VIM does not do any special processing of |formfeed| control +characters. Setting the 'printoptions' formfeed item will make VIM recognize +formfeed characters and continue printing the current line at the beginning +of the first line on a new page. The use of formfeed characters provides +rudimentary print control but there are certain things to be aware of. + +VIM will always start printing a line (including a line number if enabled) +containing a formfeed character, even if it is the first character on the +line. This means if a line starting with a formfeed character is the first +line of a page then VIM will print a blank page. + +Since the line number is printed at the start of printing the line containing +the formfeed character, the remainder of the line printed on the new page +will not have a line number printed for it (in the same way as the wrapped +lines of a long line when wrap in 'printoptions' is enabled). + +If the formfeed character is the last character on a line, then printing will +continue on the second line of the new page, not the first. This is due to +VIM processing the end of the line after the formfeed character and moving +down a line to continue printing. + +Due to the points made above it is recommended that when formfeed character +processing is enabled, printing of line numbers is disabled, and that form +feed characters are not the last character on a line. Even then you may need +to adjust the number of lines before a formfeed character to prevent +accidental blank pages. + +============================================================================== + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -1,4 +1,4 @@ -*quickref.txt* For Vim version 7.0aa. Last change: 2004 Jul 04 +*quickref.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -782,6 +782,8 @@ Short explanation of each option: *opti |'printexpr'| |'pexpr'| expression used to print PostScript for :hardcopy |'printfont'| |'pfn'| name of the font to be used for :hardcopy |'printheader'| |'pheader'| format of the header used for :hardcopy +|'printmbcharset'| |'pmbcs'| CJK character set to be used for :hardcopy +|'printmbfont'| |'pmbfn'| font names to be used for CJK output of :hardcopy |'printoptions'| |'popt'| controls the format of :hardcopy output |'quoteescape'| |'qe'| escape characters used in a string |'readonly'| |'ro'| disallow writing the buffer diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 7.0aa. Last change: 2004 Jul 01 +*syntax.txt* For Vim version 7.0aa. Last change: 2004 Jul 06 VIM REFERENCE MANUAL by Bram Moolenaar @@ -812,11 +812,20 @@ is controlled by the variable dosbatch_c this should have the value 1, and for Windows 2000 it should be 2. Select the version you want with the following line: > - :let dosbatch_cmdextversion = 1 + :let dosbatch_cmdextversion = 1 If this variable is not defined it defaults to a value of 2 to support Windows 2000. +A second option covers whether *.btm files should be detected as type +"dosbatch" (MS-DOS batch files) or type "btm" (4DOS batch files). The latter +is used by default. You may select the former with the following line: > + + :let g:dosbatch_syntax_for_btm = 1 + +If this variable is undefined or zero, btm syntax is selected. + + DTD *dtd.vim* *dtd-syntax* diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -615,6 +615,8 @@ 'pheader' options.txt /*'pheader'* 'pi' options.txt /*'pi'* 'pm' options.txt /*'pm'* +'pmbcs' options.txt /*'pmbcs'* +'pmbfn' options.txt /*'pmbfn'* 'popt' options.txt /*'popt'* 'preserveindent' options.txt /*'preserveindent'* 'previewheight' options.txt /*'previewheight'* @@ -624,6 +626,8 @@ 'printexpr' options.txt /*'printexpr'* 'printfont' options.txt /*'printfont'* 'printheader' options.txt /*'printheader'* +'printmbcharset' options.txt /*'printmbcharset'* +'printmbfont' options.txt /*'printmbfont'* 'printoptions' options.txt /*'printoptions'* 'prompt' vi_diff.txt /*'prompt'* 'pt' options.txt /*'pt'* @@ -1923,8 +1927,8 @@ 90.5 usr_90.txt /*90.5* :gv gui_x11.txt /*:gv* :gvim gui_x11.txt /*:gvim* :h various.txt /*:h* -:ha various.txt /*:ha* -:hardcopy various.txt /*:hardcopy* +:ha print.txt /*:ha* +:hardcopy print.txt /*:hardcopy* :help various.txt /*:help* :helpf various.txt /*:helpf* :helpfind various.txt /*:helpfind* @@ -3046,8 +3050,8 @@ E233 gui.txt /*E233* E234 options.txt /*E234* E235 options.txt /*E235* E236 options.txt /*E236* -E237 various.txt /*E237* -E238 various.txt /*E238* +E237 print.txt /*E237* +E238 print.txt /*E238* E239 sign.txt /*E239* E24 message.txt /*E24* E240 remote.txt /*E240* @@ -3140,7 +3144,7 @@ E320 message.txt /*E320* E321 editing.txt /*E321* E322 message.txt /*E322* E323 message.txt /*E323* -E324 various.txt /*E324* +E324 print.txt /*E324* E325 usr_11.txt /*E325* E326 recover.txt /*E326* E327 gui.txt /*E327* @@ -3185,7 +3189,7 @@ E361 pattern.txt /*E361* E362 term.txt /*E362* E363 pattern.txt /*E363* E364 eval.txt /*E364* -E365 options.txt /*E365* +E365 print.txt /*E365* E366 options.txt /*E366* E367 autocmd.txt /*E367* E368 eval.txt /*E368* @@ -3284,9 +3288,9 @@ E451 os_msdos.txt /*E451* E452 os_msdos.txt /*E452* E453 os_msdos.txt /*E453* E454 os_msdos.txt /*E454* -E455 various.txt /*E455* -E456 various.txt /*E456* -E457 various.txt /*E457* +E455 print.txt /*E455* +E456 print.txt /*E456* +E457 print.txt /*E457* E458 message.txt /*E458* E459 message.txt /*E459* E46 message.txt /*E46* @@ -3454,19 +3458,19 @@ E61 pattern.txt /*E61* E610 options.txt /*E610* E611 options.txt /*E611* E612 sign.txt /*E612* -E613 options.txt /*E613* +E613 print.txt /*E613* E614 editing.txt /*E614* E615 editing.txt /*E615* E616 editing.txt /*E616* E617 options.txt /*E617* -E618 various.txt /*E618* -E619 various.txt /*E619* +E618 print.txt /*E618* +E619 print.txt /*E619* E62 pattern.txt /*E62* -E620 options.txt /*E620* -E621 various.txt /*E621* +E620 print.txt /*E620* +E621 print.txt /*E621* E622 if_cscop.txt /*E622* E623 if_cscop.txt /*E623* -E624 various.txt /*E624* +E624 print.txt /*E624* E625 if_cscop.txt /*E625* E626 if_cscop.txt /*E626* E627 netbeans.txt /*E627* @@ -3520,6 +3524,9 @@ E67 syntax.txt /*E67* E670 various.txt /*E670* E671 starting.txt /*E671* E672 starting.txt /*E672* +E673 print.txt /*E673* +E674 print.txt /*E674* +E675 print.txt /*E675* E68 pattern.txt /*E68* E69 pattern.txt /*E69* E70 pattern.txt /*E70* @@ -3882,7 +3889,7 @@ a insert.txt /*a* a' motion.txt /*a'* a( motion.txt /*a(* a) motion.txt /*a)* -a4 options.txt /*a4* +a4 print.txt /*a4* a:firstline eval.txt /*a:firstline* a:lastline eval.txt /*a:lastline* a:var eval.txt /*a:var* @@ -5205,7 +5212,7 @@ last_buffer_nr() eval.txt /*last_buffer_ lc_time-variable eval.txt /*lc_time-variable* left-right-motions motion.txt /*left-right-motions* less various.txt /*less* -letter options.txt /*letter* +letter print.txt /*letter* lex-syntax syntax.txt /*lex-syntax* lex.vim syntax.txt /*lex.vim* lhaskell.vim syntax.txt /*lhaskell.vim* @@ -5462,6 +5469,8 @@ new-5 version5.txt /*new-5* new-6 version6.txt /*new-6* new-7 version7.txt /*new-7* new-GTK-GUI version5.txt /*new-GTK-GUI* +new-KDE version7.txt /*new-KDE* +new-MzScheme version7.txt /*new-MzScheme* new-Select-mode version5.txt /*new-Select-mode* new-View version6.txt /*new-View* new-argument-list version6.txt /*new-argument-list* @@ -5490,7 +5499,6 @@ new-highlighting version5.txt /*new-high new-indent-flex version6.txt /*new-indent-flex* new-items-6 version6.txt /*new-items-6* new-items-7 version7.txt /*new-items-7* -new-kde version7.txt /*new-kde* new-line-continuation version5.txt /*new-line-continuation* new-multi-byte version5.txt /*new-multi-byte* new-multi-lang version6.txt /*new-multi-lang* @@ -5500,6 +5508,7 @@ new-options-5.2 version5.txt /*new-optio new-options-5.4 version5.txt /*new-options-5.4* new-perl-python version5.txt /*new-perl-python* new-plugins version6.txt /*new-plugins* +new-print-multi-byte version7.txt /*new-print-multi-byte* new-printing version6.txt /*new-printing* new-runtime-dir version5.txt /*new-runtime-dir* new-script version5.txt /*new-script* @@ -5589,6 +5598,8 @@ pattern-multi-items pattern.txt /*patter pattern-overview pattern.txt /*pattern-overview* pattern-searches pattern.txt /*pattern-searches* pattern.txt pattern.txt /*pattern.txt* +pdev-option print.txt /*pdev-option* +penc-option print.txt /*penc-option* perl if_perl.txt /*perl* perl-Append if_perl.txt /*perl-Append* perl-Buffer if_perl.txt /*perl-Buffer* @@ -5613,6 +5624,9 @@ perl-patterns pattern.txt /*perl-pattern perl-syntax syntax.txt /*perl-syntax* perl-using if_perl.txt /*perl-using* perl.vim syntax.txt /*perl.vim* +pexpr-option print.txt /*pexpr-option* +pfn-option print.txt /*pfn-option* +pheader-option print.txt /*pheader-option* photon-fonts os_qnx.txt /*photon-fonts* photon-gui os_qnx.txt /*photon-gui* php-syntax syntax.txt /*php-syntax* @@ -5628,16 +5642,20 @@ plugin usr_05.txt /*plugin* plugin-details filetype.txt /*plugin-details* plugin-filetype usr_41.txt /*plugin-filetype* plugin-special usr_41.txt /*plugin-special* +pmbcs-option print.txt /*pmbcs-option* +pmbfn-option print.txt /*pmbfn-option* +popt-option print.txt /*popt-option* popup-menu gui.txt /*popup-menu* popup-menu-added version5.txt /*popup-menu-added* ports-5.2 version5.txt /*ports-5.2* ports-6 version6.txt /*ports-6* postscr-syntax syntax.txt /*postscr-syntax* postscr.vim syntax.txt /*postscr.vim* -postscript-print-encoding various.txt /*postscript-print-encoding* -postscript-print-trouble various.txt /*postscript-print-trouble* -postscript-print-util various.txt /*postscript-print-util* -postscript-printing various.txt /*postscript-printing* +postscript-cjk-printing print.txt /*postscript-cjk-printing* +postscript-print-encoding print.txt /*postscript-print-encoding* +postscript-print-trouble print.txt /*postscript-print-trouble* +postscript-print-util print.txt /*postscript-print-util* +postscript-printing print.txt /*postscript-printing* ppwiz-syntax syntax.txt /*ppwiz-syntax* ppwiz.vim syntax.txt /*ppwiz.vim* press-enter message.txt /*press-enter* @@ -5645,9 +5663,12 @@ press-return message.txt /*press-return* prevcount-variable eval.txt /*prevcount-variable* preview-window windows.txt /*preview-window* prevnonblank() eval.txt /*prevnonblank()* +print-intro print.txt /*print-intro* +print-options print.txt /*print-options* +print.txt print.txt /*print.txt* printcap-syntax syntax.txt /*printcap-syntax* -printing various.txt /*printing* -printing-formfeed various.txt /*printing-formfeed* +printing print.txt /*printing* +printing-formfeed print.txt /*printing-formfeed* progname-variable eval.txt /*progname-variable* progress-syntax syntax.txt /*progress-syntax* progress.vim syntax.txt /*progress.vim* @@ -6247,6 +6268,7 @@ toggle-revins version4.txt /*toggle-revi tolower() eval.txt /*tolower()* toolbar-icon gui.txt /*toolbar-icon* toupper() eval.txt /*toupper()* +tr() eval.txt /*tr()* trojan-horse starting.txt /*trojan-horse* try-conditionals eval.txt /*try-conditionals* try-echoerr eval.txt /*try-echoerr* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 +*todo.txt* For Vim version 7.0aa. Last change: 2004 Jul 09 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,78 +30,21 @@ be worked on, but only if you sponsor Vi *known-bugs* -------------------- Known bugs and current work ----------------------- +:syn sync ccomment asdf gives a warning without a line number. + +@: doesn't work if cmdline has a ^M, requires using ^V. (Tim Chase) + +Mac: Compiling --enable-gui=athena doesn't work. Try to fix without disabling +Carbon. Otherwise adjust configure to disable darwin. (raf) + +Mac: "make install" doesn't install. + +Make aap build script work again. + + For version 7.0: - Include many PATCHES: - 8 ":hardcopy": - - support printing multi-byte characters. Patch from Motonobu - Ichimura. New (better) patch from Mike Williams (2004 Jan 20) - Updated patch: http://www.eandem.co.uk/mrw/vim/special/index.html - 7 Add patch from Wall for this one ( ~/Mail/oldmail/wall/in.00019 ): - 'flipcase' variable: upper/lowercase pairs. - Insert comma's between pairs and allow a range, make it look like - 'isfname'. E.g. ":set flipcase=a-zA-Z,xX,23-33:143-153". The colon to - separate the from and to part is optional. - Resp: no time now. - 8 Add GTK 2.3 file dialog support. Patch by Grahame Bowland, 2004 Mar 15, - but it doesn't use "initdir" or "dflt". (will update patch) - 8 Add ":n" to fnamemodify(): normalize path, remove "../" when possible. - Aric Blumer has a patch for this. - He will update the patch for 6.3. - 8 Add buffer-local autocommands? Reduces overhead for autocommands that - trigger often (inserting a character, switching mode). - :au Event do-something - E.g.: - :au BufEnter menu enable ... - :au BufLeave menu disable ... - Patch from Yakov Lerner, including test (2004 Jan 7). - He'll send updated patch. - Autocommands: - VimResized - When the Vim window has been resized (SIGWINCH) - patch from Yakov Lerner, 2003 July 24. - He'll write documentation and send updated patch. - 7 Completion of network shares, patch by Yasuhiro Matsumoto. - Update 2004 Jun 17. - How does this work? Missing comments. - gettext() Translate a message. (Patch from Yasuhiro Matsumoto) - Update 2004 Jun 17 - Missing docs. Search in 'runtimepath'? - How to get the messages into the .po files? - 8 Make it possible to delete marks. Charles Campbell has a patch that - does this with the markclear() function (2004 Jan 9). - And the ":delmark" command (2004 Feb 9) - http://mysite.verizon.net/astronaut/vim/index.html#Patch - ~/tmp/ptch.delmark.bz2 - ~/tmp/ptch.markclear - Implement setmark(markname, lnum, col [, filename]) instead? - --- responses above -- - 7 Make "5dd" on last-but-one-line not delete anything (Vi compatible). - Add flag in 'cpoptions' for this. When not present, "2dd" in the last - line should delete the last line. Patch from greenx 2002 Apr 11. - 8 Accelerators don't work in a dialog. Include patch from Martin Dalecki - (Jan 3, tested by David Harrison). Should work with Alt-o then. - 7 Use accelerators for the Motif file selection dialog. Patch from - Martin Dalecki 2002 Jan 11. - 8 Add a few more command names to the menus. Patch from Jiri Brezina - (28 feb 2002). - 7 ATTENTION dialog choices are more logical when "Delete it' appears - before "Quit". Patch by Robert Webb, 2004 May 3. - - Include flipcase patch: ~/vim/patches/wall.flipcase2 ? Make it work - for multi-byte characters. - - Win32: add options to print dialog. Patch from Vipin Aravind. - - Patch to add highlighting for whitespace. (Tom Schumm, 2003 Jul 5) - use the patch that keeps using HLF_8 if HLF_WS has not - been given values. - Add section in help files for these highlight groups? - 8 "fg" and "bg" don't work in an xterm. Get default colors from xterm - with an ESC sequence. Ideas in: ~/vim/patches/vikas.xtermcolors . - 7 Add "DefaultFG" and "DefaultBG" for the colors of the menu. (Martin - Dalecki has a patch for Motif) - - Add possibility to highlight specific columns (for Fortran). Or put a - line in between columns (e.g. for 'textwidth'). - Patch to add 'hlcolumn' from Vit Stradal, 2004 May 20. 8 Add functions: - tr(expr, from, to) translate chars (Patch from Ron Aaron, Apr 8 - 2004) strrep() Repeat a string (patch from Christophe Poucet, 2003 Sep 12, also contains XX) Alt: repeat(expr, count) werkt ook voor lists. @@ -140,7 +83,75 @@ For version 7.0: search() Add optional offset argument. Add 'n' flag. (patch from Nikolai Weibull 2003 Jan 13) - --- + 8 Make it possible to delete marks. Charles Campbell has a patch that + does this with the markclear() function (2004 Jan 9). + And the ":delmark" command (2004 Feb 9) + http://mysite.verizon.net/astronaut/vim/index.html#Patch + ~/tmp/ptch.delmark.bz2 + ~/tmp/ptch.markclear + Implement setmark(markname, lnum [, col [, filename]]) instead? + When "lnum" is zero delete the mark. + When "filename" has no wildcards and there is no matching buffer, add + the buffer (unlisted). + Patch for \xnn (Ciaran McCreesh) 2004 Jul 7 + --- awaiting updated patch --- + 7 Add patch from Wall for this one ( ~/Mail/oldmail/wall/in.00019 ): + 'flipcase' variable: upper/lowercase pairs. + Insert comma's between pairs and allow a range, make it look like + 'isfname'. E.g. ":set flipcase=a-zA-Z,xX,23-33:143-153". The colon to + separate the from and to part is optional. + Resp: no time now. + 8 Add GTK 2.3 file dialog support. Patch by Grahame Bowland, 2004 Mar 15, + but it doesn't use "initdir" or "dflt". (will update patch) + 8 Add ":n" to fnamemodify(): normalize path, remove "../" when possible. + Aric Blumer has a patch for this. + He will update the patch for 6.3. + 8 Add buffer-local autocommands? Reduces overhead for autocommands that + trigger often (inserting a character, switching mode). + :au Event do-something + E.g.: + :au BufEnter menu enable ... + :au BufLeave menu disable ... + Patch from Yakov Lerner, including test (2004 Jan 7). + He'll send updated patch. + Autocommands: + VimResized - When the Vim window has been resized (SIGWINCH) + patch from Yakov Lerner, 2003 July 24. + He'll write documentation and send updated patch. + 7 Completion of network shares, patch by Yasuhiro Matsumoto. + Update 2004 Jun 17. + How does this work? Missing comments. + gettext() Translate a message. (Patch from Yasuhiro Matsumoto) + Update 2004 Jun 17 + Missing docs. Search in 'runtimepath'? + How to get the messages into the .po files? + --- did not respond (yet) -- + 7 Make "5dd" on last-but-one-line not delete anything (Vi compatible). + Add flag in 'cpoptions' for this. When not present, "2dd" in the last + line should delete the last line. Patch from greenx 2002 Apr 11. + 8 Accelerators don't work in a dialog. Include patch from Martin Dalecki + (Jan 3, tested by David Harrison). Should work with Alt-o then. + 7 Use accelerators for the Motif file selection dialog. Patch from + Martin Dalecki 2002 Jan 11. + 8 Add a few more command names to the menus. Patch from Jiri Brezina + (28 feb 2002). + 7 ATTENTION dialog choices are more logical when "Delete it' appears + before "Quit". Patch by Robert Webb, 2004 May 3. + - Include flipcase patch: ~/vim/patches/wall.flipcase2 ? Make it work + for multi-byte characters. + - Win32: add options to print dialog. Patch from Vipin Aravind. + - Patch to add highlighting for whitespace. (Tom Schumm, 2003 Jul 5) + use the patch that keeps using HLF_8 if HLF_WS has not + been given values. + Add section in help files for these highlight groups? + 8 "fg" and "bg" don't work in an xterm. Get default colors from xterm + with an ESC sequence. Ideas in: ~/vim/patches/vikas.xtermcolors . + 7 Add "DefaultFG" and "DefaultBG" for the colors of the menu. (Martin + Dalecki has a patch for Motif) + - Add possibility to highlight specific columns (for Fortran). Or put a + line in between columns (e.g. for 'textwidth'). + Patch to add 'hlcolumn' from Vit Stradal, 2004 May 20. + 8 Add functions: confirm() add "flags" argument, with 'v' for vertical layout and 'c' for console dialog. (Haegg) Flemming Madsen has a patch for the 'c' flag diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 7.0aa. Last change: 2004 Jun 18 +*various.txt* For Vim version 7.0aa. Last change: 2004 Jul 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -8,8 +8,7 @@ Various commands *various* 1. Various commands |various-cmds| 2. Online help |online-help| -3. Printing |printing| -4. Using Vim like less or more |less| +3. Using Vim like less or more |less| ============================================================================== 1. Various commands *various-cmds* @@ -722,369 +721,6 @@ Hints for translators: languages in the specified directory. ============================================================================== -3. Printing *printing* - -On MS-Windows Vim can print your text on any installed printer. On other -systems a PostScript file is produced. This can be directly sent to a -PostScript printer. For other printers a program like ghostscript needs to be -used. - -3.1 PostScript Printing |postscript-printing| -3.2 PostScript Printing Encoding |postscript-print-encoding| -3.3 PostScript Printing Troubleshooting |postscript-print-trouble| -3.4 PostScript Utilities |postscript-print-util| -3.5 Formfeed Characters |printing-formfeed| - -{not in Vi} -{only available when compiled with |+printer| feature} - - *:ha* *:hardcopy* *E237* *E238* *E324* -:[range]ha[rdcopy][!] [arguments] - Send [range] lines (default whole file) to the - printer. - - On MS-Windows a dialog is displayed to allow selection - of printer, paper size etc. To skip the dialog, use - the [!]. In this case the printer defined by - 'printdevice' is used, or, if 'printdevice' is empty, - the system default printer. - - For systems other than MS-Windows, PostScript is - written in a temp file and 'printexpr' is used to - actually print it. Then [arguments] can be used by - 'printexpr' through |v:cmdarg|. Otherwise [arguments] - is ignored. 'printoptions' can be used to specify - paper size, duplex, etc. - -:[range]ha[rdcopy][!] >{filename} - As above, but write the resulting PostScript in file - {filename}. - Things like "%" are expanded |cmdline-special| - Careful: An existing file is silently overwritten. - {only available when compiled with the |+postscript| - feature} - On MS-Windows use the "print to file" feature of the - printer driver. - -Progress is displayed during printing as a page number and a percentage. To -abort printing use the interrupt key (CTRL-C or, on MS-systems, CTRL-Break). - -Printer output is controlled by the 'printfont' and 'printoptions' options. -'printheader' specifies the format of a page header. - -The printed file is always limited to the selected margins, irrespective of -the current window's 'wrap' or 'linebreak' settings. The "wrap" item in -'printoptions' can be used to switch wrapping off. -The current highlighting colors are used in the printout, with the following -considerations: -1) The normal background is always rendered as white (i.e. blank paper.) -2) White text or the default foreground is rendered as black, so that it shows - up! -3) If 'background' is "dark", then the colours are darkened to compensate for - the fact that otherwise they would be too bright to show up clearly on - white paper. - - -3.1 PostScript Printing *postscript-printing* - *E455* *E456* *E457* *E624* -Provided you have enough disk space there should be no problems generating a -PostScript file. You need to have the runtime files correctly installed (if -you can find the help files, they probably are). - -There are currently a number of limitations with PostScript printing: - -- 'printfont' - The font name is ignored (the Courier family is always used - - it should be available on all PostScript printers) but the font size is - used. - -- 'printoptions' - The duplex setting is used when generating PostScript - output, but it is up to the printer to take notice of the setting. If the - printer does not support duplex printing then it should be silently ignored. - Some printers, however, don't print at all. - -- 8-bit support - While a number of 8-bit print character encodings are - supported it is possible that some characters will not print. Whether a - character will print depends on the font in the printer knowing the - character. Missing characters will be replaced with an upside down question - mark, or a space if that character is also not known by the font. It may be - possible to get all the characters in an encoding to print by installing a - new version of the Courier font family. - -- Multi-byte support - Currently VIM will try to convert multi-byte characters - to the 8-bit encoding specified by 'printencoding' (or latin1 if it is - empty). Any characters that are not successfully converted are shown as - unknown characters. Printing will fail if VIM cannot convert the multi-byte - to the 8-bit encoding. - - -3.2 Custom 8-bit Print Character Encodings *postscript-print-encoding* - *E618* *E619* -To use your own print character encoding when printing 8-bit character data -you need to define your own PostScript font encoding vector. Details on how -to to define a font encoding vector is beyond the scope of this help file, but -you can find details in the PostScript Language Reference Manual, 3rd Edition, -published by Addison-Wesley and available in PDF form at -http://www.adobe.com/. The following describes what you need to do for VIM to -locate and use your print character encoding. - -i. Decide on a unique name for your encoding vector, one that does not clash - with any of the recognized or standard encoding names that VIM uses (see - |encoding-names| for a list), and that no one else is likely to use. -ii. Copy $VIMRUNTIME/print/latin1.ps to the print subdirectory in your - 'runtimepath' and rename it with your unique name. -iii. Edit your renamed copy of latin1.ps, replacing all occurrences of latin1 - with your unique name (don't forget the line starting %%Title:), and - modify the array of glyph names to define your new encoding vector. The - array must have exactly 256 entries or you will not be able to print! -iv. Within VIM, set 'printencoding' to your unique encoding name and then - print your file. VIM will now use your custom print character encoding. - -VIM will report an error with the resource file if you change the order or -content of the first 3 lines, other than the name of the encoding on the line -starting %%Title: or the version number on the line starting %%Version:. - -[Technical explanation for those that know PostScript - VIM looks for a file -with the same name as the encoding it will use when printing. The file -defines a new PostScript Encoding resource called /VIM-name, where name is the -print character encoding VIM will use.] - - -3.3 PostScript Printing Troubleshooting *postscript-print-trouble* - *E621* -Usually the only sign of a problem when printing with PostScript is that your -printout does not appear. If you are lucky you may get a printed page that -tells you the PostScript operator that generated the error that prevented the -print job completing. - -There are a number of possible causes as to why the printing may have failed: - -- Wrong version of the prolog resource file. The prolog resource file - contains some PostScript that VIM needs to be able to print. Each version - of VIM needs one particular version. Make sure you have correctly installed - the runtime files, and don't have any old versions of a file called prolog - in the print directory in your 'runtimepath' directory. - -- Paper size. Some PostScript printers will abort printing a file if they do - not support the requested paper size. By default VIM uses A4 paper. Find - out what size paper your printer normally uses and set the appropriate paper - size with 'printoptions'. If you cannot find the name of the paper used, - measure a sheet and compare it with the table of supported paper sizes listed - for 'printoptions', using the paper that is closest in both width AND height. - Note: The dimensions of actual paper may vary slightly from the ones listed. - If there is no paper listed close enough, then you may want to try psresize - from PSUtils, discussed below. - -- Two-sided printing (duplex). Normally a PostScript printer that does not - support two-sided printing will ignore any request to do it. However, some - printers may abort the job altogether. Try printing with duplex turned off. - Note: Duplex prints can be achieved manually using PS utils - see below. - -- Collated printing. As with Duplex printing, most PostScript printers that - do not support collating printouts will ignore a request to do so. Some may - not. Try printing with collation turned off. - -- Syntax highlighting. Some print management code may prevent the generated - PostScript file from being printed on a black and white printer when syntax - highlighting is turned on, even if solid black is the only color used. Try - printing with syntax highlighting turned off. - -A safe printoptions setting to try is: > - - :set printoptions=paper:A4,duplex:off,collate:n,syntax:n - -Replace "A4" with the paper size that best matches your printer paper. - - -3.4 PostScript Utilities *postscript-print-util* - -3.4.1 Ghostscript - -Ghostscript is a PostScript and PDF interpreter that can be used to display -and print on non-PostScript printers PostScript and PDF files. It can also -generate PDF files from PostScript. - -Ghostscript will run on a wide variety of platforms. - -There are three available versions: - -- AFPL Ghostscript (formerly Aladdin Ghostscript) which is free for - non-commercial use. It can be obtained from: - - http://www.cs.wisc.edu/~ghost/ - -- GNU Ghostscript which is available under the GNU General Public License. It - can be obtained from: - - ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/gnu/ - -- A commercial version for inclusion in commercial products. - -Additional information on Ghostscript can also be found at: - - http://www.ghostscript.com/ - -Support for a number of non PostScript printers is provided in the -distribution as standard, but if you cannot find support for your printer -check the Ghostscript site for other printers not included by default. - - -3.4.2 Ghostscript Previewers. - -The interface to Ghostscript is very primitive so a number of graphical front -ends have been created. These allow easier PostScript file selection, -previewing at different zoom levels, and printing. Check supplied -documentation for full details. - -X11 - -- Ghostview. Obtainable from: - - http://www.cs.wisc.edu/~ghost/gv/ - -- gv. Derived from Ghostview. Obtainable from: - - http://wwwthep.physik.uni-mainz.de/~plass/gv/ - - Copies (possibly not the most recent) can be found at: - - http://www.cs.wisc.edu/~ghost/gv/ - -OpenVMS - -- Is apparently supported in the main code now (untested). See: - - http://wwwthep.physik.uni-mainz.de/~plass/gv/ - -Windows and OS/2 - -- GSview. Obtainable from: - - http://www.cs.wisc.edu/~ghost/gsview/ - -DOS - -- ps_view. Obtainable from: - - ftp://ftp.pg.gda.pl/pub/TeX/support/ps_view/ - ftp://ftp.dante.de/tex-archive/support/ps_view/ - -Linux - -- GSview. Linux version of the popular Windows and OS/2 previewer. - Obtainable from: - - http://www.cs.wisc.edu/~ghost/gsview/ - -- BMV. Different from Ghostview and gv in that it doesn't use X but svgalib. - Obtainable from: - - ftp://sunsite.unc.edu/pub/Linux/apps/graphics/viewers/svga/bmv-1.2.tgz - - -3.4.3 PSUtils - -PSUtils is a collection of utility programs for manipulating PostScript -documents. Binary distributions are available for many platforms, as well as -the full source. PSUtils can be found at: - - http://knackered.org/angus/psutils - -The utilities of interest include: - -- psnup. Convert PS files for N-up printing. -- psselect. Select page range and order of printing. -- psresize. Change the page size. -- psbook. Reorder and lay out pages ready for making a book. - -The output of one program can be used as the input to the next, allowing for -complex print document creation. - - -N-UP PRINTING - -The psnup utility takes an existing PostScript file generated from VIM and -convert it to an n-up version. The simplest way to create a 2-up printout is -to first create a PostScript file with: > - - :hardcopy > test.ps - -Then on your command line execute: > - - psnup -n 2 test.ps final.ps - -Note: You may get warnings from some Ghostscript previewers for files produced -by psnup - these may safely be ignored. - -Finally print the file final.ps to your PostScript printer with your -platform's print command. (You will need to delete the two PostScript files -afterwards yourself.) 'printexpr' could be modified to perform this extra -step before printing. - - -ALTERNATE DUPLEX PRINTING - -It is possible to achieve a poor man's version of duplex printing using the PS -utility psselect. This utility has options -e and -o for printing just the -even or odd pages of a PS file respectively. - -First generate a PS file with the 'hardcopy' command, then generate a new -files with all the odd and even numbered pages with: > - - psselect -o test.ps odd.ps - psselect -e test.ps even.ps - -Next print odd.ps with your platform's normal print command. Then take the -print output, turn it over and place it back in the paper feeder. Now print -even.ps with your platform's print command. All the even pages should now -appear on the back of the odd pages. - -There a couple of points to bear in mind: - -1. Position of the first page. If the first page is on top of the printout - when printing the odd pages then you need to reverse the order that the odd - pages are printed. This can be done with the -r option to psselect. This - will ensure page 2 is printed on the back of page 1. - Note: it is better to reverse the odd numbered pages rather than the even - numbered in case there are an odd number of pages in the original PS file. - -2. Paper flipping. When turning over the paper with the odd pages printed on - them you may have to either flip them horizontally (along the long edge) or - vertically (along the short edge), as well as possibly rotating them 180 - degrees. All this depends on the printer - it will be more obvious for - desktop ink jets than for small office laser printers where the paper path - is hidden from view. - - -3.5 Formfeed Characters *printing-formfeed* - -By default VIM does not do any special processing of |formfeed| control -characters. Setting the 'printoptions' formfeed item will make VIM recognize -formfeed characters and continue printing the current line at the beginning -of the first line on a new page. The use of formfeed characters provides -rudimentary print control but there are certain things to be aware of. - -VIM will always start printing a line (including a line number if enabled) -containing a formfeed character, even if it is the first character on the -line. This means if a line starting with a formfeed character is the first -line of a page then VIM will print a blank page. - -Since the line number is printed at the start of printing the line containing -the formfeed character, the remainder of the line printed on the new page -will not have a line number printed for it (in the same way as the wrapped -lines of a long line when wrap in 'printoptions' is enabled). - -If the formfeed character is the last character on a line, then printing will -continue on the second line of the new page, not the first. This is due to -VIM processing the end of the line after the formfeed character and moving -down a line to continue printing. - -Due to the points made above it is recommended that when formfeed character -processing is enabled, printing of line numbers is disabled, and that form -feed characters are not the last character on a line. Even then you may need -to adjust the number of lines before a formfeed character to prevent -accidental blank pages. - -============================================================================== 4. Using Vim like less or more *less* If you use the less or more program to view a file, you don't get syntax diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -79,6 +79,13 @@ The MzScheme interpreter is supported. | The |:mzscheme| command can be used to execute MzScheme commands. The |:mzfile| command can be used to execute an MzScheme script file. +Printing multi-byte text *new-print-multi-byte* +------------------ + +The |:hardcopy| command now supports printing multi-byte characters. +The 'printmbcharset' and 'printmbfont' options are used for this. +Also see |postscript-cjk-printing|. (Mike Williams) + Various new items *new-items-7* ----------------- @@ -98,27 +105,31 @@ Options: ~ 'numberwidth' Minimal width of the space used for the 'number' option. (Emmanuel Renieris) 'mzquantum' Time in msec to schedule MzScheme threads. +'printmbcharset' CJK character set to be used for :hardcopy +'printmbfont' font names to be used for CJK output of :hardcopy Ex commands: ~ Win32: The ":winpos" command now also works in the console. (Vipin Aravind) -:startreplace Start Replace mode. (Charles Campbell) +|:startreplace| Start Replace mode. (Charles Campbell) -:0file Removes the name of the buffer. (Charles Campbell) +|:0file| Removes the name of the buffer. (Charles Campbell) New functions: ~ +tr(expr, from, to) |tr()| Translate characters. (Ron Aaron) + New autocommand events: ~ -InsertEnter starting Insert or Replace mode -InsertChange going from Insert to Replace mode or back -InsertLeave leaving Insert or Replace mode +|InsertEnter| starting Insert or Replace mode +|InsertChange| going from Insert to Replace mode or back +|InsertLeave| leaving Insert or Replace mode -ColorScheme after loading a color scheme +|ColorScheme| after loading a color scheme New Syntax/Indent/FTplugin files: ~ @@ -143,6 +154,8 @@ IMPROVEMENTS *improvements-7* ":helpgrep" accepts a language specifier after the pattern: "pat@it". +Move the help for printing to a separate help file. It's quite a lot now. + ":breakadd here" and ":breakdel here" can be used to set or delete a breakpoint at the cursor. diff --git a/runtime/doc/vimtutor.man b/runtime/doc/vimtutor.man --- a/runtime/doc/vimtutor.man +++ b/runtime/doc/vimtutor.man @@ -1,8 +1,6 @@ - +VIMTUTOR(1) VIMTUTOR(1) -VIMTUTOR(1) VIMTUTOR(1) - NAME vimtutor - the Vim tutor @@ -11,18 +9,17 @@ SYNOPSIS vimtutor [language] DESCRIPTION - Vimtutor starts the Vim tutor. It copies the tutor file - first, so that it can be modified without changing the - original file. + Vimtutor starts the Vim tutor. It copies the tutor file first, so that + it can be modified without changing the original file. + + The Vimtutor is useful for people that want to learn their first Vim + commands. - The Vimtutor is useful for people that want to learn their - first Vim commands. - - The optional [language] argument is the two-letter name of - a language, like "it" or "es". If the [language] argument - is missing, the language of the current locale will be - used. If a tutor in this language is available, it will - be used. Otherwise the English version will be used. + The optional [language] argument is the two-letter name of a language, + like "it" or "es". If the [language] argument is missing, the language + of the current locale will be used. If a tutor in this language is + available, it will be used. Otherwise the English version will be + used. Vim is always started in Vi compatible mode. @@ -31,36 +28,19 @@ FILES The Vimtutor text file(s). /usr/local/lib/vim/tutor/tutor.vim - The Vim script used to copy the Vimtutor - text file. + The Vim script used to copy the Vimtutor text file. AUTHOR - The Vimtutor was originally written for Vi by Michael C. - Pierce and Robert K. Ware, Colorado School of Mines using - ideas supplied by Charles Smith, Colorado State Univer- - sity. E-mail: bware@mines.colorado.edu. - It was modified for Vim by Bram Moolenaar. For the names - of the translators see the tutor files. + The Vimtutor was originally written for Vi by Michael C. Pierce and + Robert K. Ware, Colorado School of Mines using ideas supplied by + Charles Smith, Colorado State University. E-mail: bware@mines.col- + orado.edu. + It was modified for Vim by Bram Moolenaar. For the names of the trans- + lators see the tutor files. SEE ALSO vim(1) - - - - - - - - - - - - - - - 2001 April 2 1 - - + 2001 April 2 VIMTUTOR(1) diff --git a/runtime/filetype.vim b/runtime/filetype.vim --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2004 Jul 01 +" Last Change: 2004 Jul 06 " Listen very carefully, I will say this only once if exists("did_load_filetypes") @@ -205,13 +205,20 @@ endfun au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb " Batch file for MSDOS. -au BufNewFile,BufRead *.bat,*.btm,*.sys setf dosbatch +au BufNewFile,BufRead *.bat,*.sys setf dosbatch " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " Batch file for 4DOS -au BufNewFile,BufRead *.btm setf btm +au BufNewFile,BufRead *.btm call FTbtm() +fun! FTbtm() + if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm + setf dosbatch + else + setf btm + endif +endfun " BC calculator au BufNewFile,BufRead *.bc setf bc diff --git a/runtime/ftplugin/abaqus.vim b/runtime/ftplugin/abaqus.vim --- a/runtime/ftplugin/abaqus.vim +++ b/runtime/ftplugin/abaqus.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Abaqus finite element input file (www.abaqus.com) " Maintainer: Carl Osterwisch -" Last Change: 2004 May +" Last Change: 2004 Jul 06 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") | finish | endif @@ -27,6 +27,10 @@ setlocal include=\\<\\cINPUT\\s*= " Remove characters up to the first = when evaluating filenames setlocal includeexpr=substitute(v:fname,'.\\{-}=','','') +" Remove comma from valid filename characters since it is used to +" separate keyword parameters +setlocal isfname-=, + " Define format of comment lines (see 'formatoptions' for uses) setlocal comments=:** setlocal commentstring=**%s diff --git a/runtime/ftplugin/btm.vim b/runtime/ftplugin/btm.vim new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/btm.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: BTM +" Maintainer: Bram Moolenaar +" Last Change: 2004 Jul 06 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Behaves just like dosbatch +runtime! ftplugin/dosbatch.vim ftplugin/dosbatch_*.vim ftplugin/dosbatch/*.vim diff --git a/runtime/ftplugin/config.vim b/runtime/ftplugin/config.vim --- a/runtime/ftplugin/config.vim +++ b/runtime/ftplugin/config.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: config " Maintainer: Dan Sharp -" Last Changed: 2003 Sep 29 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -30,7 +30,7 @@ endif " Change the :browse e filter to primarily show configure-related files. if has("gui_win32") - let b:browsefilter="Configure Scripts (configure.*)\tconfigure.*\n" . + let b:browsefilter="Configure Scripts (configure.*, config.*)\tconfigure*;config.*\n" . \ s:browsefilter endif diff --git a/runtime/ftplugin/dosbatch.vim b/runtime/ftplugin/dosbatch.vim --- a/runtime/ftplugin/dosbatch.vim +++ b/runtime/ftplugin/dosbatch.vim @@ -17,5 +17,5 @@ setlocal formatoptions-=t formatoptions+ " Define patterns for the browse file filter if has("gui_win32") && !exists("b:browsefilter") - let b:browsefilter = "DOS Batch Files (*.bat, *.cmd)\t*.bat;*.cmd\nAll Files (*.*)\t*.*\n" + let b:browsefilter = "DOS Batch Files (*.bat, *.btm, *.cmd)\t*.bat;*.btm;*.cmd\nAll Files (*.*)\t*.*\n" endif diff --git a/runtime/ftplugin/html.vim b/runtime/ftplugin/html.vim --- a/runtime/ftplugin/html.vim +++ b/runtime/ftplugin/html.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: html " Maintainer: Dan Sharp -" Last Changed: 2004 May 11 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -26,7 +26,7 @@ endif " Change the :browse e filter to primarily show HTML-related files. if has("gui_win32") - let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm*\n" . + let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" . \ "JavaScript Files (*.js)\t*.js\n" . \ "Cascading StyleSheets (*.css)\t*.css\n" . \ "All Files (*.*)\t*.*\n" diff --git a/runtime/ftplugin/jsp.vim b/runtime/ftplugin/jsp.vim --- a/runtime/ftplugin/jsp.vim +++ b/runtime/ftplugin/jsp.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: jsp " Maintainer: Dan Sharp -" Last Changed: 2003 Sep 29 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -14,7 +14,7 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" let s:browsefilter = "Java Files (*.java)\t*.java\n" . - \ "HTML Files (*.html, *.htm)\t*.htm*\n" . + \ "HTML Files (*.html, *.htm)\t*.html;*.htm\n" . \ "All Files (*.*)\t*.*\n" let s:match_words = "" diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim --- a/runtime/ftplugin/php.vim +++ b/runtime/ftplugin/php.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: php " Maintainer: Dan Sharp -" Last Changed: 2003 Sep 29 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -13,7 +13,7 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "HTML Files (*.html, *.htm)\t*.htm*\n" . +let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" . \ "All Files (*.*)\t*.*\n" let s:match_words = "" diff --git a/runtime/ftplugin/xhtml.vim b/runtime/ftplugin/xhtml.vim --- a/runtime/ftplugin/xhtml.vim +++ b/runtime/ftplugin/xhtml.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: xhtml " Maintainer: Dan Sharp -" Last Changed: 2004 May 11 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -13,7 +13,7 @@ set cpo-=C " Define some defaults in case the included ftplugins don't set them. let s:undo_ftplugin = "" -let s:browsefilter = "HTML Files (*.html, *.htm)\t*.htm*\n" . +let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" . \ "XML Files (*.xml)\t*.xml\n" . \ "All Files (*.*)\t*.*\n" let s:match_words = "" @@ -56,7 +56,7 @@ endif " Change the :browse e filter to primarily show tcsh-related files. if has("gui_win32") - let b:browsefilter=s:browsefilter + let b:browsefilter="XHTML files (*.xhtml, *.xhtm)\t*.xhtml;*.xhtm\n" . s:browsefilter endif " Undo the stuff we changed. diff --git a/runtime/ftplugin/xslt.vim b/runtime/ftplugin/xslt.vim --- a/runtime/ftplugin/xslt.vim +++ b/runtime/ftplugin/xslt.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: xslt " Maintainer: Dan Sharp -" Last Changed: 2002 Nov 26 +" Last Changed: 2004 Jul 08 " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin if exists("b:did_ftplugin") | finish | endif @@ -12,5 +12,5 @@ let b:did_ftplugin = 1 " Change the :browse e filter to primarily show xsd-related files. if has("gui_win32") && exists("b:browsefilter") - let b:browsefilter="XSLT Files (*.xsl,*.xslt)\t*.xsl,*.xslt\n" . b:browsefilter + let b:browsefilter="XSLT Files (*.xsl,*.xslt)\t*.xsl;*.xslt\n" . b:browsefilter endif diff --git a/runtime/optwin.vim b/runtime/optwin.vim --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1,7 +1,7 @@ " These commands create the option window. " " Maintainer: Bram Moolenaar -" Last Change: 2004 Jul 03 +" Last Change: 2004 Jul 05 " If there already is an option window, jump to that one. if bufwinnr("option-window") > 0 @@ -563,18 +563,28 @@ endif if has("printer") call Header("printing") + call append("$", "printoptions\tlist of items that control the format of :hardcopy output") + call OptionG("popt", &popt) call append("$", "printdevice\tname of the printer to be used for :hardcopy") call OptionG("pdev", &pdev) - call append("$", "printencoding\tencoding used to print the PostScript file for :hardcopy") - call OptionG("penc", &penc) - call append("$", "printexpr\texpression used to print the PostScript file for :hardcopy") - call OptionG("pexpr", &pexpr) + if has("postscript") + call append("$", "printexpr\texpression used to print the PostScript file for :hardcopy") + call OptionG("pexpr", &pexpr) + endif call append("$", "printfont\tname of the font to be used for :hardcopy") call OptionG("pfn", &pfn) call append("$", "printheader\tformat of the header used for :hardcopy") call OptionG("pheader", &pheader) - call append("$", "printoptions\tlist of items that control the format of :hardcopy output") - call OptionG("popt", &popt) + if has("postscript") + call append("$", "printencoding\tencoding used to print the PostScript file for :hardcopy") + call OptionG("penc", &penc) + endif + if has("multi_byte") + call append("$", "printmbcharset\tthe CJK character set to be used for CJK output from :hardcopy") + call OptionG("pmbcs", &pmbcs) + call append("$", "printmbfont\tlist of font names to be used for CJK output from :hardcopy") + call OptionG("pmbfn", &pmbfn) + endif endif call Header("messages and info") diff --git a/runtime/plugin/NetrwFileHandlers.vim b/runtime/plugin/NetrwFileHandlers.vim --- a/runtime/plugin/NetrwFileHandlers.vim +++ b/runtime/plugin/NetrwFileHandlers.vim @@ -1,33 +1,125 @@ " NetrwFileHandlers: contains various extension-based file handlers for -" netrw's browser +" netrw's browsers' x command " Author: Charles E. Campbell, Jr. -" Date: Jul 02, 2004 -" Version: 2 +" Date: Jul 06, 2004 +" Version: 3 " --------------------------------------------------------------------- " NetrwFileHandler_html: handles html when the user hits "x" when the " cursor is atop a *.html file -fun! NetrwFileHandler_html(webpage) -" call Dfunc("NetrwFileHandler_html(".a:webpage.")") +fun! NetrwFileHandler_html(pagefile) +" call Dfunc("NetrwFileHandler_html(".a:pagefile.")") + + let page= substitute(a:pagefile,'^','file://','') - let host= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/.*$','\1','e') -" call Decho("host<".host.">") - - if host == hostname() || host == substitute(hostname(),'\..*$','','e') - let page= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/','file://\1/'.expand("$HOME").'/','e') + if executable("mozilla") +" call Decho("executing !mozilla ".page) + exe "!mozilla ".page + elseif executable("netscape") +" call Decho("executing !netscape ".page) + exe "!netscape ".page else - let page= substitute(a:webpage,'^\w\+://\%(\w*@\)\=\(\w\+\)/','http://\1/','e') +" call Dret("NetrwFileHandler_html 0") + return 0 endif +" call Dret("NetrwFileHandler_html 1") + return 1 +endfun + +" --------------------------------------------------------------------- +" NetrwFileHandler_htm: handles html when the user hits "x" when the +" cursor is atop a *.htm file +fun! NetrwFileHandler_htm(pagefile) +" call Dfunc("NetrwFileHandler_htm(".a:pagefile.")") + + let page= substitute(a:pagefile,'^','file://','') + if executable("mozilla") -" call Decho("executing !mozilla ".page) +" call Decho("executing !mozilla ".page) exe "!mozilla ".page elseif executable("netscape") -" call Decho("executing !netscape ".page) +" call Decho("executing !netscape ".page) exe "!netscape ".page + else +" call Dret("NetrwFileHandler_htm 0") + return 0 endif -" call Dret("NetrwFileHandler_html") +" call Dret("NetrwFileHandler_htm 1") + return 1 endfun " --------------------------------------------------------------------- +" NetrwFileHandler_jpg: +fun! NetrwFileHandler_jpg(jpgfile) +" call Dfunc("NetrwFileHandler_jpg(jpgfile<".a:jpgfile.">)") + + if executable("gimp") + exe "silent! !gimp -s ".a:jpgfile + elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") + exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".a:jpgfile + else +" call Dret("NetrwFileHandler_jpg 0") + return 0 + endif + +" call Dret("NetrwFileHandler_jpg 1") + return 1 +endfun + +" --------------------------------------------------------------------- +" NetrwFileHandler_gif: +fun! NetrwFileHandler_gif(giffile) +" call Dfunc("NetrwFileHandler_gif(giffile<".a:giffile.">)") + + if executable("gimp") + exe "silent! !gimp -s ".a:giffile + elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") + exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".a:giffile + else +" call Dret("NetrwFileHandler_gif 0") + return 0 + endif + +" call Dret("NetrwFileHandler_gif 1") + return 1 +endfun + +" --------------------------------------------------------------------- +" NetrwFileHandler_pnm: +fun! NetrwFileHandler_pnm(pnmfile) +" call Dfunc("NetrwFileHandler_pnm(pnmfile<".a:pnmfile.">)") + + if executable("gimp") + exe "silent! !gimp -s ".a:pnmfile + elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") + exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".a:pnmfile + else +" call Dret("NetrwFileHandler_pnm 0") + return 0 + endif + +" call Dret("NetrwFileHandler_pnm 1") + return 1 +endfun + +" --------------------------------------------------------------------- +" NetrwFileHandler_bmp: +fun! NetrwFileHandler_bmp(bmpfile) +" call Dfunc("NetrwFileHandler_bmp(bmpfile<".a:bmpfile.">)") + + if executable("gimp") + exe "silent! !gimp -s ".a:bmpfile + elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") + exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".a:bmpfile + else +" call Dret("NetrwFileHandler_bmp 0") + return 0 + endif + +" call Dret("NetrwFileHandler_bmp 1") + return 1 +endfun + +" --------------------------------------------------------------------- diff --git a/runtime/plugin/explorer.vim b/runtime/plugin/explorer.vim deleted file mode 100644 --- a/runtime/plugin/explorer.vim +++ /dev/null @@ -1,1326 +0,0 @@ -"============================================================================= -" File: explorer.vim -" Author: M A Aziz Ahmed (aziz@acorn-networks.com - doesn't work) -" Last Change: 2004 Jun 22 -" Version: 2.5 + changes -" Additions by Mark Waggoner (waggoner@aracnet.com) et al. -"----------------------------------------------------------------------------- -" This file implements a file explorer. -"----------------------------------------------------------------------------- -" Normally, this file will reside in the plugins directory and be -" automatically sourced. If not, you must manually source this file -" using :source explorer.vim -" -" To use it, just edit a directory (vi dirname) or type :Explore to -" launch the file explorer in the current window, or :Sexplore to split -" the current window and launch explorer there. -" -" If the current buffer is modified, the window is always split. -" -" It is also possible to delete files and rename files within explorer. -" See :help file-explorer for more details -" -"----------------------------------------------------------------------------- -" Update history removed, it's not very interesting. -" Contributors were: Doug Potts, Bram Moolenaar, Thomas Köhler -"============================================================================= - -" Has this already been loaded? -if exists("loaded_explorer") - finish -endif -let loaded_explorer=1 - -" Line continuation used here -let s:cpo_save = &cpo -set cpo&vim - -"--- -" Default settings for global configuration variables - -" Split vertically instead of horizontally? -if !exists("g:explVertical") - let g:explVertical=0 -endif - -" How big to make the window? Set to "" to avoid resizing -if !exists("g:explWinSize") - let g:explWinSize=15 -endif - -" When opening a new file/directory, split below current window (or -" above)? 1 = below, 0 = to above -if !exists("g:explSplitBelow") - let g:explSplitBelow = &splitbelow -endif - -" Split to right of current window (or to left)? -" 1 = to right, 0 = to left -if !exists("g:explSplitRight") - let g:explSplitRight = &splitright -endif - -" Start the first explorer window... -" Defaults to be the same as explSplitBelow -if !exists("g:explStartBelow") - let g:explStartBelow = g:explSplitBelow -endif - -" Start the first explorer window... -" Defaults to be the same as explSplitRight -if !exists("g:explStartRight") - let g:explStartRight = g:explSplitRight -endif - -" Show detailed help? -if !exists("g:explDetailedHelp") - let g:explDetailedHelp=0 -endif - -" Show file size and dates? -if !exists("g:explDetailedList") - let g:explDetailedList=0 -endif - -" Format for the date -if !exists("g:explDateFormat") - let g:explDateFormat="%d %b %Y %H:%M" -endif - -" Files to hide -if !exists("g:explHideFiles") - let g:explHideFiles='' -endif - -" Field to sort by -if !exists("g:explSortBy") - let g:explSortBy='name' -endif - -" Segregate directories? 1, 0, or -1 -if !exists("g:explDirsFirst") - let g:explDirsFirst=1 -endif - -" Segregate items in suffixes option? 1, 0, or -1 -if !exists("g:explSuffixesLast") - let g:explSuffixesLast=1 -endif - -" Include separator lines between directories, files, and suffixes? -if !exists("g:explUseSeparators") - let g:explUseSeparators=0 -endif - -" Execute file handler -if !exists("g:explFileHandler") - if has("win32") - " for Win32 use rundll32 - function! s:explFileHandlerWin32(fn) - exec 'silent !start rundll32 url.dll,FileProtocolHandler "' - \ . escape(a:fn, '%#') . '"' - endfunction - let g:explFileHandler = "explFileHandlerWin32" - - elseif has("unix") - " for KDE use kfmclient, for GNUME use gnome-open - if executable("kfmclient") - let g:explFileHandlerCmd = "kfmclient exec" - elseif executable("gnome-open") - let g:explFileHandlerCmd = "gnome-open" - else - let g:explFileHandlerCmd = "" - endif - if g:explFileHandlerCmd != "" - function! s:explFileHandlerUnix(fn) - if &shellredir =~ "%s" - let redir = substitute(&shellredir, "%s", "/dev/null", "") - else - let redir = &shellredir . "/dev/null" - endif - " Need to escape % and # but not spaces. - exec "silent !" . g:explFileHandlerCmd . " '" . escape(a:fn, '%#') . "'" . redir - endfunction - let g:explFileHandler = "explFileHandlerUnix" - endif - endif -endif - -"--- -" script variables - these are the same across all -" explorer windows - -" characters that must be escaped for a regular expression -let s:escregexp = '/*^$.~\' - -" characters that must be escaped for filenames -if has("dos16") || has("dos32") || has("win16") || has("win32") || has("os2") - let s:escfilename = ' %#' -else - let s:escfilename = ' \%#[]' -endif - - -" A line to use for separating sections -let s:separator='"---------------------------------------------------' - -"--- -" Create commands - -if !exists(':Explore') - command -n=? -complete=dir Explore :call s:StartExplorer(0, '') -endif -if !exists(':Sexplore') - command -n=? -complete=dir Sexplore :call s:StartExplorer(1, '') -endif - -"--- -" Start the explorer using the preferences from the global variables -" -function! s:StartExplorer(split, start_dir) - let startcmd = "edit" - if a:start_dir != "" - let fname=a:start_dir - else - let fname = expand("%:p:h") - endif - if fname == "" - let fname = getcwd() - endif - - " Create a variable to use if splitting vertically - let splitMode = "" - if g:explVertical == 1 - let splitMode = "vertical" - endif - - " Save the user's settings for splitbelow and splitright - let savesplitbelow = &splitbelow - let savesplitright = &splitright - - if a:split || &modified - let startcmd = splitMode . " " . g:explWinSize . "new " . fname - let &splitbelow = g:explStartBelow - let &splitright = g:explStartRight - else - let startcmd = "edit " . fname - endif - silent execute startcmd - let &splitbelow = savesplitbelow - let &splitright = savesplitright -endfunction - -"--- -" This is the main entry for 'editing' a directory -" -function! s:EditDir() - " Get out of here right away if this isn't a directory! - let name = expand("%") - if name == "" - let name = expand("%:p") - endif - if !isdirectory(name) - return - endif - - " Turn off the swapfile, set the buffer type so that it won't get - " written, and so that it will get deleted when it gets hidden. - setlocal noreadonly modifiable - setlocal noswapfile - setlocal buftype=nowrite - setlocal bufhidden=delete - " Don't wrap around long lines - setlocal nowrap - - " No need for any insertmode abbreviations, since we don't allow - " insertions anyway! - iabc - - " Long or short listing? Use the global variable the first time - " explorer is called, after that use the script variable as set by - " the interactive user. - if exists("s:longlist") - let w:longlist = s:longlist - else - let w:longlist = g:explDetailedList - endif - - " Show keyboard shortcuts? - if exists("s:longhelp") - let w:longhelp = s:longhelp - else - let w:longhelp = g:explDetailedHelp - endif - - " Set the sort based on the global variables the first time. If you - " later change the sort order, it will be retained in the s:sortby - " variable for the next time you open explorer - let w:sortdirection=1 - let w:sortdirlabel = "" - let w:sorttype = "" - if exists("s:sortby") - let sortby=s:sortby - else - let sortby=g:explSortBy - endif - if sortby =~ "reverse" - let w:sortdirection=-1 - let w:sortdirlabel = "reverse " - endif - if sortby =~ "date" - let w:sorttype = "date" - elseif sortby =~ "size" - let w:sorttype = "size" - else - let w:sorttype = "name" - endif - call s:SetSuffixesLast() - - " If directory is already loaded, don't open it again! - if line('$') > 1 - setlocal readonly nomodifiable - return - endif - - " Get the complete path to the directory to look at with a slash at - " the end. This also removes "/../" and "/./" things. - let b:completePath = s:Path(expand("%:p")) - - " Add a slash at the end - if b:completePath !~ '/$' - let b:completePath = b:completePath . '/' - endif - - " escape special characters for exec commands - let b:completePathEsc = escape(b:completePath, s:escfilename) - let b:parentDirEsc = substitute(b:completePathEsc, '/[^/]*/$', '/', 'g') - - " Set up syntax highlighting - " Something wrong with the evaluation of the conditional though... - if has("syntax") && exists("g:syntax_on") && !has("syntax_items") - syn match browseSynopsis "^\"[ -].*" - syn match browseDirectory "[^\"].*/ " - syn match browseDirectory "[^\"].*/$" - syn match browseCurDir "^\"= .*$" - syn match browseSortBy "^\" Sorted by .*$" contains=browseSuffixInfo - syn match browseSuffixInfo "(.*)$" contained - syn match browseFilter "^\" Not Showing:.*$" - syn match browseFiletime "««\d\+$" - exec('syn match browseSuffixes "' . b:suffixesHighlight . '"') - - "hi def link browseSynopsis PreProc - hi def link browseSynopsis Special - hi def link browseDirectory Directory - hi def link browseCurDir Statement - hi def link browseSortBy String - hi def link browseSuffixInfo Type - hi def link browseFilter String - hi def link browseFiletime Ignore - hi def link browseSuffixes Type - endif - - " Set filter for hiding files - let b:filterFormula=substitute(g:explHideFiles, '\([^\\]\),', '\1\\|', 'g') - if b:filterFormula != '' - let b:filtering="\nNot showing: " . b:filterFormula - else - let b:filtering="" - endif - - " Show the files - call s:ShowDirectory() - - " Set up mappings for this buffer - let cpo_save = &cpo - set cpo&vim - nnoremap :call EditEntry("","edit") - nnoremap - :exec ("silent e " . b:parentDirEsc) - if exists("g:explFileHandler") - nnoremap x :call ExecuteEntry() - endif - nnoremap o :call OpenEntry() - nnoremap O :call OpenEntryPrevWindow() - nnoremap p :call EditEntry("","pedit") - nnoremap ? :call ToggleHelp() - nnoremap a :call ShowAllFiles() - nnoremap R :call RenameFile() - nnoremap D :. call DeleteFile() - vnoremap D :call DeleteFile() - nnoremap i :call ToggleLongList() - nnoremap s :call SortSelect() - nnoremap r :call SortReverse() - nnoremap c :exec "cd ".b:completePathEsc - nnoremap <2-leftmouse> :call DoubleClick() - if exists("*ExplorerCustomMap") - call ExplorerCustomMap() - endif - let &cpo = cpo_save - - " prevent the buffer from being modified - setlocal readonly nomodifiable -endfunction - -"--- -" Determine the number of windows open to this buffer number. -" Care of Yegappan Lakshman. Thanks! -fun! s:BufInWindows(bnum) - let cnt = 0 - let winnum = 1 - while 1 - let bufnum = winbufnr(winnum) - if bufnum < 0 - break - endif - if bufnum == a:bnum - let cnt = cnt + 1 - endif - let winnum = winnum + 1 - endwhile - - return cnt -endfunction - -" If this is the only window, open file in a new window -" Otherwise, open file in the most recently visited window -" -function! s:OpenEntryPrevWindow() - " Figure out if there are any other windows - let n = winnr() - wincmd p - " No other window? Then open a new one - if n == winnr() - call s:OpenEntry() - " Other windows exist - else - " Check if the previous buffer is modified - ask if they want to save! - " Was it modified, and is it the only window open to this file - if &modified && s:BufInWindows(winbufnr(winnr())) < 2 - let bufname = bufname(winbufnr(winnr())) - - let action=confirm("Save Changes in " . bufname . "?","&Yes\n&No\n&Cancel") - " Yes - try to save - if there is an error, cancel - if action == 1 - let v:errmsg = "" - silent w - if v:errmsg != "" - echoerr "Unable to write buffer!" - wincmd p - return - endif - " No, abandon changes - elseif action == 2 - set nomodified - echomsg "Warning, abandoning changes in " . bufname - " Cancel (or any other result), don't do the open - else - wincmd p - return - endif - endif - wincmd p - call s:EditEntry("wincmd p","edit") - endif -endfunction - - -"--- -" Open a file or directory in a new window. -" Use g:explSplitBelow and g:explSplitRight to decide where to put the -" split window, and resize the original explorer window if it is -" larger than g:explWinSize -" -function! s:OpenEntry() - " Are we on a line with a file name? - let l = getline(".") - if l =~ '^"' - return - endif - - " Copy window settings to script settings - let s:sortby=w:sortdirlabel . w:sorttype - let s:longhelp = w:longhelp - let s:longlist = w:longlist - - " Get the window number of the explorer window - let n = winnr() - - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " Figure out how to do the split based on the user's preferences. - " We want to split to the (left,right,top,bottom) of the explorer - " window, but we want to extract the screen real-estate from the - " window next to the explorer if possible. - " - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - if g:explVertical - if g:explSplitRight - let there="wincmd h" - let back ="wincmd l" - let right=1 - let below=0 - else - let there="wincmd l" - let back ="wincmd h" - let right=0 - let below=0 - endif - else - if g:explSplitBelow - let there="wincmd k" - let back ="wincmd j" - let right=0 - let below=1 - else - let there="wincmd j" - let back ="wincmd k" - let right=0 - let below=0 - endif - endif - - " Get the file name - let fn=s:GetFullFileName() - - " Attempt to go to adjacent window - exec(back) - " If no adjacent window, set splitright and splitbelow appropriately - if n == winnr() - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below - endif - - " Create a variable to use if splitting vertically - let splitMode = "" - if g:explVertical == 1 - let splitMode = "vertical" - endif - - " Is it a directory? If so, get a real path to it instead of - " relative path. This also removes "/../" and "/./" things. - if isdirectory(fn) - let fn = fnamemodify(fn, ":p") - endif - - " Open the new window - exec("silent " . splitMode." sp " . escape(fn,s:escfilename)) - - " resize the explorer window if it is larger than the requested size - exec(there) - if g:explWinSize =~ '[0-9]\+' && winheight("") > g:explWinSize - exec("silent ".splitMode." resize ".g:explWinSize) - endif - exec(back) - - " Restore splitmode settings - let &splitbelow=savesplitbelow - let &splitright=savesplitright - -endfunction - -function! s:ExecuteEntry() - " Are we on a line with a file name? - let l = getline(".") - if l =~ '^"' - return - endif - - " Get the file name - let fn = s:GetFullFileName() - if has("win32") && fn =~ '^//' - let fn = substitute(fn, '/', '\\', 'g') - endif - exec "call " . g:explFileHandler . "(fn)" -endfunction - -"--- -" Double click with the mouse -" -function s:DoubleClick() - if expand("") =~ '[\\/]$' - call s:EditEntry("","edit") " directory: open in this window - else - call s:OpenEntryPrevWindow() " file: open in another window - endif -endfun - -"--- -" Open file or directory in the same window as the explorer is -" currently in -" -function! s:EditEntry(movefirst,editcmd) - " Are we on a line with a file name? - let l = getline(".") - if l =~ '^"' - return - endif - - " Copy window settings to script settings - let s:sortby=w:sortdirlabel . w:sorttype - let s:longhelp = w:longhelp - let s:longlist = w:longlist - - " Get the file name - let fn = s:GetFullFileName() - if isdirectory(fn) - " This removes "/../" and "/./" things. - let fn = fnamemodify(fn, ":p") - endif - - " Move to desired window if needed - exec(a:movefirst) - " Edit the file/dir - exec(a:editcmd . " " . escape(fn,s:escfilename)) -endfunction - - -"--- -" Create a regular expression out of the suffixes option for sorting -" and set a string to indicate whether we are sorting with the -" suffixes at the end (or the beginning) -" -function! s:SetSuffixesLast() - let b:suffixesRegexp = '\(' . substitute(escape(&suffixes,s:escregexp),',','\\|','g') . '\)$' - let b:suffixesHighlight = '^[^"].*\(' . substitute(escape(&suffixes,s:escregexp),',','\\|','g') . '\)\( \|$\)' - if has("fname_case") - let b:suffixesRegexp = '\C' . b:suffixesRegexp - let b:suffixesHighlight = '\C' . b:suffixesHighlight - else - let b:suffixesRegexp = '\c' . b:suffixesRegexp - let b:suffixesHighlight = '\c' . b:suffixesHighlight - endif - if g:explSuffixesLast > 0 && &suffixes != "" - let b:suffixeslast=" (" . &suffixes . " at end of list)" - elseif g:explSuffixesLast < 0 && &suffixes != "" - let b:suffixeslast=" (" . &suffixes . " at start of list)" - else - let b:suffixeslast=" ('suffixes' mixed with files)" - endif -endfunction - -"--- -" Show the header and contents of the directory -" -function! s:ShowDirectory() - "Delete all lines - 1,$d _ - " Prevent a report of our actions from showing up - let oldRep=&report - let save_sc = &sc - set report=10000 nosc - - " Add the header - call s:AddHeader() - $d _ - - " Display the files - - " Get a list of all the files - let files = s:Path(glob(b:completePathEsc . "*")) - if files != "" && files !~ "\n$" - let files = files . "\n" - endif - - " Add the dot files now, making sure "." is not included! - let files = files . substitute(s:Path(glob(b:completePathEsc . ".*")), "[^\n]*/./\\=\n", '' , '') - if files != "" && files !~ "\n$" - let files = files . "\n" - endif - - " Are there any files left after filtering? - if files != "" - normal! mt - put =files - let b:maxFileLen = 0 - 0 - /^"=/+1,$g/^/call s:MarkDirs() - keepjumps normal! `t - call s:AddFileInfo() - endif - - normal! zz - - " Move to first directory in the listing - 0 - /^"=/+1 - - " Do the sort - call s:SortListing("Loaded contents of ".b:completePath.". ") - - " Move to first directory in the listing - 0 - /^"=/+1 - - let &report=oldRep - let &sc = save_sc - -endfunction - -"--- -" Mark which items are directories - called once for each file name -" must be used only when size/date is not displayed -" -function! s:MarkDirs() - let oldRep=&report - set report=1000 - "Remove slashes if added - s;/$;;e - "Removes all the leading slashes and adds slashes at the end of directories - s;^.*\\\([^\\]*\)$;\1;e - s;^.*/\([^/]*\)$;\1;e - "normal! ^ - let currLine=getline(".") - if isdirectory(b:completePath . currLine) - s;$;/; - let fileLen=strlen(currLine)+1 - else - let fileLen=strlen(currLine) - if (b:filterFormula!="") && (currLine =~ b:filterFormula) - " Don't show the file if it is to be filtered. - d _ - endif - endif - if fileLen > b:maxFileLen - let b:maxFileLen=fileLen - endif - let &report=oldRep -endfunction - -"--- -" Make sure a path has proper form -" -function! s:Path(p) - if has("dos16") || has("dos32") || has("win16") || has("win32") || has("os2") - return substitute(a:p,'\\','/','g') - else - return a:p - endif -endfunction - -"--- -" Extract the file name from a line in several different forms -" -function! s:GetFullFileNameEsc() - return s:EscapeFilename(s:GetFullFileName()) -endfunction - -function! s:GetFileNameEsc() - return s:EscapeFilename(s:GetFileName()) -endfunction - -function! s:EscapeFilename(name) - return escape(a:name,s:escfilename) -endfunction - - -function! s:GetFullFileName() - return s:ExtractFullFileName(getline(".")) -endfunction - -function! s:GetFileName() - return s:ExtractFileName(getline(".")) -endfunction - -function! s:ExtractFullFileName(line) - let fn=s:ExtractFileName(a:line) - if fn == '/' - return b:completePath - else - return b:completePath . s:ExtractFileName(a:line) - endif -endfunction - -function! s:ExtractFileName(line) - return substitute(strpart(a:line,0,b:maxFileLen),'\s\+$','','') -endfunction - -"--- -" Get the size of the file -function! s:ExtractFileSize(line) - if (w:longlist==0) - return getfsize(s:ExtractFileName(a:line)) - else - return strpart(a:line,b:maxFileLen+2,b:maxFileSizeLen) - endif -endfunction - -"--- -" Get the date of the file as a number -function! s:ExtractFileDate(line) - if w:longlist==0 - return getftime(s:ExtractFileName(a:line)) - else - return strpart(matchstr(strpart(a:line,b:maxFileLen+b:maxFileSizeLen+4),"««.*"),2) + 0 - endif -endfunction - - -"--- -" Add the header with help information -" -function! s:AddHeader() - let save_f=@f - 1 - if w:longhelp==1 - let @f="\" : open file or directory\n" - \."\" o : open new window for file/directory\n" - \."\" O : open file in previously visited window\n" - \."\" p : preview the file\n" - if exists("g:explFileHandler") - let @f=@f."\" x : execute file or directory\n" - endif - let @f=@f - \."\" i : toggle size/date listing\n" - \."\" s : select sort field r : reverse sort\n" - \."\" - : go up one level c : cd to this dir\n" - \."\" R : rename file D : delete file\n" - \."\" :help file-explorer for detailed help\n" - else - let @f="\" Press ? for keyboard shortcuts\n" - endif - let @f=@f."\" Sorted by ".w:sortdirlabel.w:sorttype.b:suffixeslast.b:filtering."\n" - let @f=@f."\"= ".b:completePath."\n" - put! f - let @f=save_f -endfunction - - -"--- -" Show the size and date for each file -" -function! s:AddFileInfo() - let save_sc = &sc - set nosc - - " Mark our starting point - normal! mt - - call s:RemoveSeparators() - - " Remove all info - 0 - /^"=/+1,$g/^/call setline(line("."),s:GetFileName()) - - " Add info if requested - if w:longlist==1 - " Add file size and calculate maximum length of file size field - let b:maxFileSizeLen = 0 - 0 - /^"=/+1,$g/^/let fn=s:GetFullFileName() | - \let fileSize=getfsize(fn) | - \let fileSizeLen=strlen(fileSize) | - \if fileSizeLen > b:maxFileSizeLen | - \ let b:maxFileSizeLen = fileSizeLen | - \endif | - \exec "normal! ".(b:maxFileLen-strlen(getline("."))+2)."A \" | - \exec 's/$/'.fileSize.'/' - - " Right justify the file sizes and - " add file modification date - 0 - /^"=/+1,$g/^/let fn=s:GetFullFileName() | - \exec "normal! A \$b".(b:maxFileLen+b:maxFileSizeLen-strlen(getline("."))+3)."i \\"_x" | - \exec 's/$/ '.escape(s:FileModDate(fn), '/').'/' - setlocal nomodified - endif - - call s:AddSeparators() - - " return to start - keepjumps normal! `t - - let &sc = save_sc -endfunction - - -"---- -" Get the modification time for a file -" -function! s:FileModDate(name) - let filetime=getftime(a:name) - if filetime > 0 - return strftime(g:explDateFormat,filetime) . " ««" . filetime - else - return "" - endif -endfunction - -"--- -" Delete a file or files -" -function! s:DeleteFile() range - let oldRep = &report - let &report = 1000 - - let filesDeleted = 0 - let stopDel = 0 - let delAll = 0 - let currLine = a:firstline - let lastLine = a:lastline - setlocal noreadonly modifiable - - while ((currLine <= lastLine) && (stopDel==0)) - exec(currLine) - let fileName=s:GetFullFileName() - if isdirectory(fileName) - echo fileName." : Directory deletion not supported yet" - let currLine = currLine + 1 - else - if delAll == 0 - let sure=input("Delete ".fileName." (y/n/a/q)? ") - if sure=="a" - let delAll = 1 - endif - endif - if (sure=="y") || (sure=="a") - let success=delete(fileName) - if success!=0 - exec (" ") - echo "\nCannot delete ".fileName - let currLine = currLine + 1 - else - d _ - let filesDeleted = filesDeleted + 1 - let lastLine = lastLine - 1 - endif - elseif sure=="q" - let stopDel = 1 - elseif sure=="n" - let currLine = currLine + 1 - endif - endif - endwhile - echo "\n".filesDeleted." files deleted" - let &report = oldRep - setlocal nomodified - setlocal readonly nomodifiable -endfunction - -"--- -" Rename a file -" -function! s:RenameFile() - let fileName=s:GetFullFileName() - setlocal noreadonly modifiable - if isdirectory(fileName) - echo "Directory renaming not supported yet" - elseif filereadable(fileName) - let altName=input("Rename ".fileName." to : ") - echo " " - if altName=="" - setlocal readonly nomodifiable - return - endif - let success=rename(fileName, b:completePath.altName) - if success!=0 - echo "Cannot rename ".fileName. " to ".altName - else - echo "Renamed ".fileName." to ".altName - let oldRep=&report - set report=1000 - e! - let &report=oldRep - endif - endif - setlocal nomodified - setlocal readonly nomodifiable -endfunction - -"--- -" Toggle between short and long help -" -function! s:ToggleHelp() - if exists("w:longhelp") && w:longhelp==0 - let w:longhelp=1 - let s:longhelp=1 - else - let w:longhelp=0 - let s:longhelp=0 - endif - " Allow modification - setlocal noreadonly modifiable - call s:UpdateHeader() - " Disallow modification - setlocal readonly nomodifiable -endfunction - -"--- -" Update the header -" -function! s:UpdateHeader() - let oldRep=&report - set report=10000 - " Save position - normal! mt - " Remove old header - 0 - 1,/^"=/ d _ - " Add new header - call s:AddHeader() - " Go back where we came from if possible - 0 - if line("'t") != 0 - keepjumps normal! `t - endif - - let &report=oldRep - setlocal nomodified -endfunction - -"--- -" Toggle long vs. short listing -" -function! s:ToggleLongList() - setlocal noreadonly modifiable - if exists("w:longlist") && w:longlist==1 - let w:longlist=0 - let s:longlist=0 - else - let w:longlist=1 - let s:longlist=1 - endif - call s:AddFileInfo() - setlocal readonly nomodifiable -endfunction - -"--- -" Show all files - remove filtering -" -function! s:ShowAllFiles() - setlocal noreadonly modifiable - let b:filterFormula="" - let b:filtering="" - call s:ShowDirectory() - setlocal readonly nomodifiable -endfunction - -"--- -" Figure out what section we are in -" -function! s:GetSection() - let fn=s:GetFileName() - let section="file" - if fn =~ '/$' - let section="directory" - elseif fn =~ b:suffixesRegexp - let section="suffixes" - endif - return section -endfunction - -"--- -" Remove section separators -" -function! s:RemoveSeparators() - if !g:explUseSeparators - return - endif - 0 - silent! exec '/^"=/+1,$g/^' . s:separator . "/d _" -endfunction - -"--- -" Add section separators -" between directories and files if they are separated -" between files and 'suffixes' files if they are separated -function! s:AddSeparators() - if !g:explUseSeparators - return - endif - 0 - /^"=/+1 - let lastsec=s:GetSection() - +1 - .,$g/^/let sec=s:GetSection() | - \if g:explDirsFirst != 0 && sec != lastsec && - \ (lastsec == "directory" || sec == "directory") | - \ exec "normal! I" . s:separator . "\n\" | - \elseif g:explSuffixesLast != 0 && sec != lastsec && - \ (lastsec == "suffixes" || sec == "suffixes") | - \ exec "normal! I" . s:separator . "\n\" | - \endif | - \let lastsec=sec -endfunction - -"--- -" General string comparison function -" -function! s:StrCmp(line1, line2, direction) - if a:line1 < a:line2 - return -a:direction - elseif a:line1 > a:line2 - return a:direction - else - return 0 - endif -endfunction - -"--- -" Function for use with Sort(), to compare the file names -" Default sort is to put in alphabetical order, but with all directory -" names before all file names -" -function! s:FileNameCmp(line1, line2, direction) - let f1=s:ExtractFileName(a:line1) - let f2=s:ExtractFileName(a:line2) - - " Put directory names before file names - if (g:explDirsFirst != 0) && (f1 =~ '\/$') && (f2 !~ '\/$') - return -g:explDirsFirst - elseif (g:explDirsFirst != 0) && (f1 !~ '\/$') && (f2 =~ '\/$') - return g:explDirsFirst - elseif (g:explSuffixesLast != 0) && (f1 =~ b:suffixesRegexp) && (f2 !~ b:suffixesRegexp) - return g:explSuffixesLast - elseif (g:explSuffixesLast != 0) && (f1 !~ b:suffixesRegexp) && (f2 =~ b:suffixesRegexp) - return -g:explSuffixesLast - else - return s:StrCmp(substitute(f1, "/$", "", ""), substitute(f2, "/$", "", ""), a:direction) - endif - -endfunction - -"--- -" Function for use with Sort(), to compare the file modification dates -" Default sort is to put NEWEST files first. Reverse will put oldest -" files first -" -function! s:FileDateCmp(line1, line2, direction) - let f1=s:ExtractFileName(a:line1) - let f2=s:ExtractFileName(a:line2) - let t1=s:ExtractFileDate(a:line1) - let t2=s:ExtractFileDate(a:line2) - - " Put directory names before file names - if (g:explDirsFirst != 0) && (f1 =~ '\/$') && (f2 !~ '\/$') - return -g:explDirsFirst - elseif (g:explDirsFirst != 0) && (f1 !~ '\/$') && (f2 =~ '\/$') - return g:explDirsFirst - elseif (g:explSuffixesLast != 0) && (f1 =~ b:suffixesRegexp) && (f2 !~ b:suffixesRegexp) - return g:explSuffixesLast - elseif (g:explSuffixesLast != 0) && (f1 !~ b:suffixesRegexp) && (f2 =~ b:suffixesRegexp) - return -g:explSuffixesLast - elseif t1 > t2 - return -a:direction - elseif t1 < t2 - return a:direction - else - return s:StrCmp(substitute(f1, "/$", "", ""), substitute(f2, "/$", "", ""), 1) - endif -endfunction - -"--- -" Function for use with Sort(), to compare the file sizes -" Default sort is to put largest files first. Reverse will put -" smallest files first -" -function! s:FileSizeCmp(line1, line2, direction) - let f1=s:ExtractFileName(a:line1) - let f2=s:ExtractFileName(a:line2) - let s1=s:ExtractFileSize(a:line1) - let s2=s:ExtractFileSize(a:line2) - - if (g:explDirsFirst != 0) && (f1 =~ '\/$') && (f2 !~ '\/$') - return -g:explDirsFirst - elseif (g:explDirsFirst != 0) && (f1 !~ '\/$') && (f2 =~ '\/$') - return g:explDirsFirst - elseif (g:explSuffixesLast != 0) && (f1 =~ b:suffixesRegexp) && (f2 !~ b:suffixesRegexp) - return g:explSuffixesLast - elseif (g:explSuffixesLast != 0) && (f1 !~ b:suffixesRegexp) && (f2 =~ b:suffixesRegexp) - return -g:explSuffixesLast - elseif s1 > s2 - return -a:direction - elseif s1 < s2 - return a:direction - else - return s:StrCmp(substitute(f1, "/$", "", ""), substitute(f2, "/$", "", ""), 1) - endif -endfunction - -"--- -" Sort lines. SortR() is called recursively. -" -function! s:SortR(start, end, cmp, direction) - - " Bottom of the recursion if start reaches end - if a:start >= a:end - return - endif - " - let partition = a:start - 1 - let middle = partition - let partStr = getline((a:start + a:end) / 2) - let i = a:start - while (i <= a:end) - let str = getline(i) - exec "let result = " . a:cmp . "(str, partStr, " . a:direction . ")" - if result <= 0 - " Need to put it before the partition. Swap lines i and partition. - let partition = partition + 1 - if result == 0 - let middle = partition - endif - if i != partition - let str2 = getline(partition) - call setline(i, str2) - call setline(partition, str) - endif - endif - let i = i + 1 - endwhile - - " Now we have a pointer to the "middle" element, as far as partitioning - " goes, which could be anywhere before the partition. Make sure it is at - " the end of the partition. - if middle != partition - let str = getline(middle) - let str2 = getline(partition) - call setline(middle, str2) - call setline(partition, str) - endif - call s:SortR(a:start, partition - 1, a:cmp,a:direction) - call s:SortR(partition + 1, a:end, a:cmp,a:direction) -endfunction - -"--- -" To Sort a range of lines, pass the range to Sort() along with the name of a -" function that will compare two lines. -" -function! s:Sort(cmp,direction) range - call s:SortR(a:firstline, a:lastline, a:cmp, a:direction) -endfunction - -"--- -" Reverse the current sort order -" -function! s:SortReverse() - if exists("w:sortdirection") && w:sortdirection == -1 - let w:sortdirection = 1 - let w:sortdirlabel = "" - else - let w:sortdirection = -1 - let w:sortdirlabel = "reverse " - endif - let s:sortby=w:sortdirlabel . w:sorttype - call s:SortListing("") -endfunction - -"--- -" Toggle through the different sort orders -" -function! s:SortSelect() - " Select the next sort option - if !exists("w:sorttype") - let w:sorttype="name" - elseif w:sorttype == "name" - let w:sorttype="size" - elseif w:sorttype == "size" - let w:sorttype="date" - else - let w:sorttype="name" - endif - let s:sortby=w:sortdirlabel . w:sorttype - call s:SortListing("") -endfunction - -"--- -" Sort the file listing -" -function! s:SortListing(msg) - " Save the line we start on so we can go back there when done - " sorting - let startline = getline(".") - let col=col(".") - let lin=line(".") - - " Allow modification - setlocal noreadonly modifiable - - " Send a message about what we're doing - " Don't really need this - it can cause hit return prompts -" echo a:msg . "Sorting by" . w:sortdirlabel . w:sorttype - - " Create a regular expression out of the suffixes option in case - " we need it. - call s:SetSuffixesLast() - - " Remove section separators - call s:RemoveSeparators() - - " Do the sort - 0 - if w:sorttype == "size" - /^"=/+1,$call s:Sort("s:FileSizeCmp",w:sortdirection) - elseif w:sorttype == "date" - /^"=/+1,$call s:Sort("s:FileDateCmp",w:sortdirection) - else - /^"=/+1,$call s:Sort("s:FileNameCmp",w:sortdirection) - endif - - " Replace the header with updated information - call s:UpdateHeader() - - " Restore section separators - call s:AddSeparators() - - " Return to the position we started on - 0 - if search('\m^'.escape(startline,s:escregexp),'W') <= 0 - execute lin - endif - execute "normal!" col . "|" - - " Disallow modification - setlocal nomodified - setlocal readonly nomodifiable - -endfunction - -"--- -" Setup for editing directories after starting up by going to each window. -" Required for "vim -o filename dirname" -" -function! s:EditAll() - if winbufnr(2) == -1 - return - endif - let cmd = winrestcmd() - let curwin = winnr() - while 1 - wincmd w - if winnr() == curwin - break - endif - call s:EditDir() - endwhile - exe cmd -endfunction - -"--- -" Set up the autocommand to allow directories to be edited -" -augroup fileExplorer - au! - " Fill the window when entering the buffer; ":edit dir". - au BufEnter * call s:EditDir() - " Set the window variables after a split; ":split". - au WinEnter * if !exists("w:sortdirection") | call s:EditDir() | endif - " Fill the windows after Vim has started up. - au VimEnter * call s:EditAll() -augroup end - -" restore 'cpo' -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/runtime/plugin/netrw.vim b/runtime/plugin/netrw.vim --- a/runtime/plugin/netrw.vim +++ b/runtime/plugin/netrw.vim @@ -1,7 +1,7 @@ " netrw.vim: Handles file transfer and remote directory listing across a network -" Last Change: Jun 30, 2004 +" Last Change: Jul 08, 2004 " Maintainer: Charles E. Campbell, Jr. PhD -" Version: 47g ASTRO-ONLY +" Version: 47l ASTRO-ONLY " License: Vim License (see vim's :help license) " " But be doers of the word, and not only hearers, deluding your own selves @@ -12,8 +12,9 @@ if exists("loaded_netrw") || &cp finish endif -let loaded_netrw = "v47g ASTRO-ONLY" -let s:save_cpo = &cpo +let loaded_netrw = "v47l ASTRO-ONLY" +let s:save_cpo = &cpo +let loaded_explorer = 1 set cpo&vim " --------------------------------------------------------------------- @@ -74,6 +75,36 @@ if !exists("g:netrw_sort_direction") " alternative: reverse (z y x ...) let g:netrw_sort_direction= "normal" endif +if !exists("g:netrw_longlist") || g:netrw_longlist == 0 + let g:netrw_longlist= 0 +else + let g:netrw_longlist= 1 + let g:netrw_list_cmd= "ssh HOSTNAME ls -FLa -l" +endif +if !exists("g:netrw_timefmt") + let g:netrw_timefmt= "%c" +endif +if !exists("g:netrw_local_rmdir") + let g:netrw_local_rmdir= "rmdir" +endif +if !exists("g:netrw_local_rename") + if has("win32") + let g:netrw_local_rename= "ren" + elseif has("unix") + let g:netrw_local_rename= "mv" + endif +endif +if !exists("g:netrw_local_mkdir") + let g:netrw_local_mkdir= "mkdir" +endif +if !exists("g:netrw_mkdir_cmd") + let g:netrw_mkdir_cmd= "ssh HOSTNAME mkdir" +endif + +" BufEnter event ignored by decho when following variable is true +" Has a side effect that doau BufReadPost doesn't work, so +" files read by network transfer aren't appropriately highlighted. +"let g:decho_bufenter = 1 "Decho " --------------------------------------------------------------------- " Default values for global protocol variables {{{1 @@ -125,11 +156,13 @@ endif " --------------------------------------------------------------------- " Transparency Support: {{{1 -" Auto-detection for ftp://*, rcp://*, scp://*, sftp://*, http://*, dav://*, -" and rsync://* -" Should make file transfers across networks transparent. Currently I haven't -" supported appends. Hey, gotta leave something for a future ! + " File Explorer: {{{2 if version >= 600 + augroup FileExplorer + au! + au BufEnter * call LocalBrowse(expand("")) + augroup END + " Network Handler: {{{2 augroup Network au! if has("win32") @@ -328,7 +361,7 @@ fun! s:NetRead(...) " call Decho("read via ftp+.netrc (method #2)") let netrw_fname= b:netrw_fname new - set ff=unix + setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" exe "put ='get ".netrw_fname." ".tmpfile."'" if exists("g:netrw_port") && g:netrw_port != "" @@ -353,7 +386,7 @@ fun! s:NetRead(...) " call Decho("read via ftp+mipf (method #3)") let netrw_fname= b:netrw_fname new - set ff=unix + setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -444,7 +477,7 @@ fun! s:NetRead(...) " Construct execution string (four lines) which will be passed through filter let netrw_fname= b:netrw_fname new - set ff=unix + setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -538,7 +571,7 @@ fun! s:NetRead(...) unlet b:netrw_fname endif call s:NetOptionRestore() - + " call Dret("NetRead") endfun " end of NetRead @@ -614,7 +647,7 @@ fun! s:NetGetFile(readcmd, fname, method exe bufnr("#")."bwipe!" else let oldul= &ul - set ul=-1 + setlocal ul=-1 exe a:readcmd." ".v:cmdarg." ".fname if delline > 0 " wipe out last line, which should be a blank line anyway @@ -641,6 +674,11 @@ fun! s:NetGetFile(readcmd, fname, method " call Decho("calling NetReadFixup(method<".a:method."> line1=".line1." line2=".line2.")") call NetReadFixup(a:method, line1, line2) endif + + " update the Buffers menu + if has("gui") && has("gui_running") + silent! emenu Buffers.Refresh\ menu + endif " call Decho("readcmd<".a:readcmd."> cmdarg<".v:cmdarg."> fname<".a:fname."> readable=".filereadable(a:fname)) @@ -763,7 +801,7 @@ fun! s:NetWrite(...) range elseif b:netrw_method == 2 " write with ftp + <.netrc> let netrw_fname = b:netrw_fname new - set ff=unix + setlocal ff=unix exe "put ='".g:netrw_ftpmode."'" " call Decho(" NetWrite: put ='".g:netrw_ftpmode."'") exe "put ='put ".tmpfile." ".netrw_fname."'" @@ -788,7 +826,7 @@ fun! s:NetWrite(...) range elseif b:netrw_method == 3 " write with ftp + machine, id, passwd, and fname let netrw_fname= b:netrw_fname new - set ff=unix + setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -850,7 +888,7 @@ fun! s:NetWrite(...) range " Construct execution string (four lines) which will be passed through filter let netrw_fname= b:netrw_fname new - set ff=unix + setlocal ff=unix if exists("g:netrw_port") && g:netrw_port != "" put ='open '.g:netrw_machine.' '.g:netrw_port else @@ -895,7 +933,7 @@ fun! s:NetWrite(...) range let uid_machine = g:netrw_machine endif new - set ff=unix + setlocal ff=unix put ='put '.tmpfile.' '.netrw_fname norm 1Gdd " call Decho("executing: %!".g:netrw_sftp_cmd.' '.uid_machine) @@ -959,18 +997,18 @@ fun! NetBrowse(dirname) " call Decho("set up path <".path .">") " call Decho("set up fname <".fname .">") - let listcmd = substitute(g:netrw_list_cmd,'\',user.machine,'') + let listcmd = substitute(g:netrw_list_cmd,'\',user.machine,'') - " optionally sort by time (-t) or by size (-S) - if g:netrw_sort_by =~ "^t" - let listcmd= listcmd."t" - elseif g:netrw_sort_by =~ "^s" - let listcmd= listcmd."S" - endif - " optionally sort in reverse - if g:netrw_sort_direction =~ "^r" - let listcmd= listcmd."r" - endif + " optionally sort by time (-t) or by size (-S) + if g:netrw_sort_by =~ "^t" + let listcmd= listcmd."t" + elseif g:netrw_sort_by =~ "^s" + let listcmd= listcmd."S" + endif + " optionally sort in reverse + if g:netrw_sort_direction =~ "^r" + let listcmd= listcmd."r" + endif " call Decho("set up listcmd<".listcmd.">") @@ -993,12 +1031,12 @@ fun! NetBrowse(dirname) " remote-read the requested file into current buffer enew! - exe "file ".method."://".user.machine."/".path + exe "file ".method."://".user.machine."/".escape(path,' ') exe "silent doau BufReadPre ".fname silent call s:NetRead(method."://".user.machine."/".path) exe "silent doau BufReadPost ".fname - 1d - set nomod + keepjumps 1d + setlocal nomod " call Dret("NetBrowse 0 : file<".fname.">") return 0 @@ -1021,26 +1059,28 @@ fun! NetBrowse(dirname) else enew! endif - setlocal bt=nofile bh=wipe nobl - exe 'file '.bufname - set bt=nowrite bh=hide nobl - nnoremap :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),expand(""))) + setlocal ts=32 bt=nofile bh=wipe nobl + exe 'file '.escape(bufname,' ') + setlocal bt=nowrite bh=hide nobl + nnoremap :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),NetGetDir())) nnoremap :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),'./')) nnoremap - :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),'../')) nnoremap a :let g:netrw_list_showall=1exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),'./')) - nnoremap h :call NetHideEdit() - nnoremap o :exe g:netrw_winsize."wincmd s"exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),expand(""))) - nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),expand(""))) + nnoremap H :call NetHideEdit(0) + nnoremap i :call NetLongList(0) + nnoremap o :exe g:netrw_winsize."wincmd s"exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),NetGetDir())) + nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),NetGetDir())) nnoremap s :let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),'./')) - nnoremap v :exe g:netrw_winsize."wincmd v"exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),expand(""))) - nnoremap x :exe "norm! 0"call NetBrowseX(NetBrowseChgDir(expand("%"),expand(""))) - nnoremap <2-leftmouse> :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),expand(""))) + nnoremap v :exe g:netrw_winsize."wincmd v"exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),NetGetDir())) + nnoremap x :exe "norm! 0"call NetBrowseX(NetBrowseChgDir(expand("%"),NetGetDir()),1) + nnoremap <2-leftmouse> :exe "norm! 0"call NetBrowse(NetBrowseChgDir(expand("%"),NetGetDir())) exe 'nnoremap :exe "norm! 0"call NetBrowseRm("'.user.machine.'","'.path.'")' exe 'vnoremap :call NetBrowseRm("'.user.machine.'","'.path.'")' exe 'nnoremap D :exe "norm! 0"call NetBrowseRm("'.user.machine.'","'.path.'")' exe 'vnoremap D :call NetBrowseRm("'.user.machine.'","'.path.'")' exe 'nnoremap R :exe "norm! 0"call NetBrowseRename("'.user.machine.'","'.path.'")' - nnoremap ? :he netrw-dir + exe 'nnoremap M :call NetMakeDir("'.user.machine.'")' + nnoremap ? :he netrw-browse-cmds setlocal ma " Set up the banner @@ -1069,7 +1109,7 @@ fun! NetBrowse(dirname) keepjumps 1d " manipulate the directory listing (hide, sort) - set ft=netrwlist + setlocal ft=netrwlist if line("$") >= g:netrw_bannercnt if !exists("g:netrw_list_showall") if g:netrw_list_hide != "" @@ -1078,6 +1118,13 @@ fun! NetBrowse(dirname) else unlet g:netrw_list_showall endif + if g:netrw_longlist + " do a long listing; these substitutions need to be done prior to sorting + keepjumps silent /^total\s*\d\+$/d + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/ -> .*$//e' + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/\(\S\+\s\+\S\+\s\+\S\+\s\+\S\+\s\+\S\+\s\+\S\+\s\+\S\+\s\+\S\+\)\s\+\(\S\+\)$/\2\t\1/e' + exe g:netrw_bannercnt + endif if g:netrw_sort_by =~ "^n" call s:SetSort() exe 'keepjumps silent '.g:netrw_bannercnt.',$call s:NetSort()' @@ -1111,7 +1158,7 @@ fun! NetBrowseChgDir(dirname,newdir elseif newdir == './' " refresh the directory list " call Decho("refresh directory listing") - set ma + setlocal ma %d elseif newdir == '../' @@ -1139,6 +1186,18 @@ fun! NetBrowseChgDir(dirname,newdir endfun " --------------------------------------------------------------------- +" NetGetDir: it gets the directory named under the cursor +fun! NetGetDir() +" call Dfunc("NetGetDir()") + let dirname= getline(".") + if dirname =~ '\t' + let dirname= substitute(dirname,'\t.*$','','e') + endif +" call Dret("NetGetDir <".dirname.">") + return dirname +endfun + +" --------------------------------------------------------------------- " NetBrowseRm: remove a remote file or directory {{{2 fun! NetBrowseRm(usrhost,path) range " call Dfunc("NetBrowseRm(usrhost<".a:usrhost."> path<".a:path.">)") @@ -1215,7 +1274,7 @@ fun! NetBrowseRename(usrhost,path) " attempt to rename files/directories while ctr <= a:lastline - exe ctr + exe "keepjumps ".ctr norm! 0 let oldname= a:path.expand("") @@ -1234,21 +1293,52 @@ fun! NetBrowseRename(usrhost,path) " refresh the directory let curline= line(".") call NetBrowse(NetBrowseChgDir(expand("%"),'./')) - exe curline + exe "keepjumps ".curline " call Dret("NetBrowseRename") endfun " --------------------------------------------------------------------- " NetBrowseX: allows users to write custom functions to operate on {{{2 -" files given their extension -fun! NetBrowseX(fname) -" call Dfunc("NetBrowseX(".a:fname.")") +" files given their extension. Passes 0=local, 1=remote +fun! NetBrowseX(fname,remote) +" call Dfunc("NetBrowseX(".a:fname." remote=".a:remote.")") let exten= substitute(a:fname,'.*\.\(.\{-}\)','\1','e') " call Decho("exten<".exten."> "."NetrwFileHandler_".exten."():exists=".exists("*NetrwFileHandler_".exten)) if exten != "" && exists("*NetrwFileHandler_".exten) - exe "call NetrwFileHandler_".exten.'("'.a:fname.'")' + + let fname= a:fname + if a:remote == 1 + " create a local copy + let fname= tempname().".".exten +" call Decho("create a local copy of <".a:fname."> as <".fname.">") + exe "keepjumps silent bot 1new ".a:fname + let eikeep= &ei + set ei=all bh=delete + exe "w! ".fname + let &ei= eikeep + q + endif + + exe "let ret= NetrwFileHandler_".exten.'("'.fname.'")' + redraw! + + " cleanup: remove temporary file, + " delete current buffer if success with handler, + " return to prior buffer (directory listing) + if a:remote == 1 && fname != a:fname +" call Decho("deleting temporary file<".fname.">") + call delete(fname) + endif + if ret != 0 + let eikeep= &ei + set ei=all bh=delete bt=nofile + exe "norm! \" + let &ei= eikeep + redraw! + endif endif + " call Dret("NetBrowseX") endfun @@ -1276,8 +1366,8 @@ endfun " --------------------------------------------------------------------- " NetHideEdit: allows user to edit the file/directory hiding list -fun! NetHideEdit() -" call Dfunc("NetHideEdit()") +fun! NetHideEdit(mode) +" call Dfunc("NetHideEdit(mode=".a:mode.")") call inputsave() let newhide= input("Edit Hiding List: ",g:netrw_list_hide) @@ -1285,12 +1375,427 @@ fun! NetHideEdit() " refresh the listing let g:netrw_list_hide= newhide - silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./')) + if a:mode == 0 + silent call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./')) + else + silent call s:LocalBrowse(s:NetBrowseChgDir(expand("%"),'./')) + endif " call Dret("NetHideEdit") endfun -" ------------------------------------------------------------------------ +" --------------------------------------------------------------------- +" NetLongList: {{{2 +fun! NetLongList(mode) +" call Dfunc("NetLongList(mode=".a:mode.") netrw_longlist=".g:netrw_longlist) + + if g:netrw_longlist != 0 + " turn long listing off + let g:netrw_longlist = 0 + let g:netrw_list_cmd = substitute(g:netrw_list_cmd,' -l','','ge') + + else + " turn long listing on + let g:netrw_longlist = 1 + let g:netrw_list_cmd = g:netrw_list_cmd." -l" + endif + + " refresh the listing + if a:mode == 0 + silent call NetBrowse(NetBrowseChgDir(expand("%"),"./")) + else + silent call LocalBrowse(LocalBrowseChgDir(expand("%"),"./")) + endif + +" call Dret("NetLongList : g:netrw_longlist=".g:netrw_longlist) +endfun + +" --------------------------------------------------------------------- +" NetMakeDir: this function makes a directory (both local and remote) +fun! NetMakeDir(usrhost) +" call Dfunc("NetMakeDir(usrhost<".a:usrhost.">)") + + " get name of new directory from user. A bare will skip. + " if its currently a directory, also request will be skipped, but with + " a message. + call inputsave() + let newdirname= input("Please give directory name: ") + call inputrestore() + + if newdirname == "" +" call Dret("NetMakeDir : user aborted with bare ") + return + endif + + if a:usrhost == "" + + " Local mkdir: + " sanity checks + if isdirectory(newdirname) + echoerr "***warning*** <".newdirname."> is already a directory!" +" call Dret("NetMakeDir : directory<".newdirname."> exists previously") + return + endif + if filereadable(newdirname) + echoerr "***warning*** <".newdirname."> is already a file!" +" call Dret("NetMakeDir : file<".newdirname."> exists previously") + return + endif + exe "silent! !".g:netrw_local_mkdir." ".newdirname + if v:shell_error == 0 + " refresh listing + call s:LocalBrowse(".") + else + echoerr "***warning*** unable to make directory<".newdirname.">" + endif + redraw! + + else + " Remote mkdir: + let mkdircmd = substitute(g:netrw_mkdir_cmd,'\',a:usrhost,'') + let newdirname= substitute(expand("%"),'^\%(.\{-}/\)\{3}\(.*\)$','\1','').newdirname +" call Decho("exe silent! !".mkdircmd." ".newdirname) + exe "silent! !".mkdircmd." ".newdirname + if v:shell_error == 0 + " refresh listing + call s:NetBrowse(s:NetBrowseChgDir(expand("%"),'./')) + else + echoerr "***warning*** unable to make directory<".newdirname.">" + endif + redraw! + endif + +" call Dret("NetMakeDir") +endfun + +" --------------------------------------------------------------------- +" Browsing Support For Local Directories And Files: {{{1 + +" --------------------------------------------------------------------- +" LocalBrowse: supports local file/directory browsing {{{2 +fun! LocalBrowse(dirname) + +" let dirname= (a:dirname == "")? expand("%:p") : a:dirname + if !isdirectory(a:dirname) + " not a directory, ignore it + return + endif + +" " unfortunate interaction -- when putting Dfunc/Dret above + " one can no longer enter the DBG buffer. +" call Dfunc("LocalBrowse(dirname<".a:dirname.">)") + + exe 'cd '.escape(a:dirname,' ') + let dirname= getcwd()."/" +" call Decho("dirname<".dirname.">") + + " make this buffer modifiable + setlocal ma + + " --------------------------------------------------------------------- + " Perform Directory Listing: +" call Decho("Perform directory listing...") + " set up new buffer and map + let dirnamenr = bufnr(dirname) + if dirnamenr != -1 && bufname(dirnamenr) != dirname + " try removing the trailing "/" + let dirnamenr= bufnr(substitute(dirname,'/$','','e')) + endif +" call Decho("bufnr(dirname<".dirname.">)=".dirnamenr) + + if dirnamenr != -1 && bufexists(dirname) + " buffer already exists (hidden), so switch to it! + exe "b ".dirnamenr + exe 'cd '.escape(dirname,' ') +" call Decho("changed directory to<".dirname.">") + if a:dirname != "." && line("$") >= 5 +" call Dret("LocalBrowse : buffer already exists with info") + return + endif +" call Decho("buffer already exists, but needs listing (buf#".dirnamenr.")") + keepjumps %d + else +" call Dredir("ls!") +" call Decho("generate new buffer named<".dirname.">") + silent! enew! + exe 'silent! file '.escape(dirname,' ') + endif + " set standard browser options on buffer + setlocal ts=32 bt=nowrite bh=hide nobl + + " set up all the maps + nnoremap :exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),NetGetDir())) + nnoremap :exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),'./')) + nnoremap - :exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),'../')) + nnoremap a :let g:netrw_list_showall=1exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),'./')) + nnoremap H :call NetHideEdit(1) + nnoremap M :call NetMakeDir("") + nnoremap i :call NetLongList(1) + nnoremap o :exe g:netrw_winsize."wincmd s"exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),NetGetDir())) + nnoremap r :let g:netrw_sort_direction= (g:netrw_sort_direction =~ 'n')? 'r' : 'n'exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),NetGetDir())) + nnoremap s :let g:netrw_sort_by= (g:netrw_sort_by =~ 'n')? 'time' : (g:netrw_sort_by =~ 't')? 'size' : 'name'exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),'./')) + nnoremap v :exe g:netrw_winsize."wincmd v"exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),NetGetDir())) + nnoremap x :exe "norm! 0"call NetBrowseX(LocalBrowseChgDir(expand("%:p"),NetGetDir()),0) + nnoremap <2-leftmouse> :exe "norm! 0"call LocalBrowse(LocalBrowseChgDir(expand("%:p"),NetGetDir())) + exe 'nnoremap :exe "norm! 0"call LocalBrowseRm("'.expand("%:p").NetGetDir().'")' + exe 'vnoremap :call LocalBrowseRm("'.expand("%:p").NetGetDir().'")' + exe 'nnoremap D :exe "norm! 0"call LocalBrowseRm("'.expand("%:p").NetGetDir().'")' + exe 'vnoremap D :call LocalBrowseRm("'.expand("%:p").NetGetDir().'")' + exe 'nnoremap R :exe "norm! 0"call LocalBrowseRename("'.expand("%:p").NetGetDir().'")' + nnoremap ? :he netrw-dir + + " Set up the banner + keepjumps put ='\" =================' + keepjumps 1d + keepjumps put ='\" Directory Listing' + keepjumps put ='\" '.dirname + let g:netrw_bannercnt= 6 + if g:netrw_sort_by =~ "^n" + " sorted by name + let g:netrw_bannercnt= g:netrw_bannercnt + 1 + keepjumps put ='\" Sorted by '.g:netrw_sort_by + keepjumps put ='\" Sort sequence: '.g:netrw_sort_sequence + else + " sorted by size or date + keepjumps put ='\" Sorted by '.g:netrw_sort_by + endif + if g:netrw_list_hide != "" && !exists("g:netrw_list_showall") + keepjumps put ='\" Hiding: '.g:netrw_list_hide + let g:netrw_bannercnt= g:netrw_bannercnt + 1 + endif + keepjumps put ='\" =================' + + " generate the requested directory listing + call LocalBrowseList(dirname) + + " manipulate the directory listing (hide, sort) + setlocal ft=netrwlist + if line("$") >= g:netrw_bannercnt + if !exists("g:netrw_list_showall") + if g:netrw_list_hide != "" + call s:NetrwListHide() + endif + else + unlet g:netrw_list_showall + endif + if g:netrw_sort_by =~ "^n" + call s:SetSort() + exe 'keepjumps silent '.g:netrw_bannercnt.',$call s:NetSort()' + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^\d\{3}\///e' + else + exe 'keepjumps silent '.g:netrw_bannercnt.',$call s:NetSort()' + exe 'keepjumps silent '.g:netrw_bannercnt.',$s/^\d\{-}\///e' + endif + endif + exe g:netrw_bannercnt + try + exe 'cd '.escape(substitute(dirname,'/$','','e'),' ') +" call Decho("changed directory to<".dirname.">") + catch + echoerr "Not a directory: <".dirname.">" + endtry + + setlocal noma nomod + +" call Dret("LocalBrowse") +endfun + +" --------------------------------------------------------------------- +" LocalBrowseList: does the job of "ls" for local directories {{{2 +fun! LocalBrowseList(dirname) +" call Dfunc("LocalBrowseList(dirname<".a:dirname.">)") + + let dirnamelen = strlen(a:dirname) + let filelist = glob(a:dirname."*")."\n".glob(a:dirname.".*") +" call Decho("filelist<".filelist.">") + + while filelist != "" + if filelist =~ '\n' + let file = substitute(filelist,'\n.*$','','e') + let filelist = substitute(filelist,'^.\{-}\n\(.*\)$','\1','e') + else + let file = filelist + let filelist= "" + endif + let pfile= file + if isdirectory(file) + let pfile= file."/" + endif + let pfile= strpart(pfile,dirnamelen) + if g:netrw_longlist + let pfile= pfile."\t".getfsize(file)."\t".strftime(g:netrw_timefmt,getftime(file)) + endif + if g:netrw_sort_by =~ "^t" + " sort by time (handles time up to 1 quintillion seconds, US) +" call Decho("getftime(".file.")=".getftime(file)) + let t = getftime(file) + let ft = strpart("000000000000000000",1,18-strlen(t)).t +" call Decho("exe keepjumps put ='".ft.'/'.file."'") + exe "keepjumps put ='".ft.'/'.pfile."'" + elseif g:netrw_sort_by =~ "^s" + " sort by size (handles file sizes up to 1 quintillion bytes, US) +" call Decho("getfsize(".file.")=".getfsize(file)) + let sz = getfsize(file) + let fsz = strpart("000000000000000000",1,18-strlen(sz)).sz +" call Decho("exe keepjumps put ='".fsz.'/'.file."'") + exe "keepjumps put ='".fsz.'/'.pfile."'" + else + " sort by name +" call Decho("exe keepjumps put ='".file."'") + exe "keepjumps put ='".pfile."'" + endif + endwhile + +" call Dret("LocalBrowseList") +endfun + +" --------------------------------------------------------------------- +" LocalBrowseChgDir: constructs a new directory based on the current {{{2 +" directory and a new directory name +fun! LocalBrowseChgDir(dirname,newdir) +" call Dfunc("LocalBrowseChgDir(dirname<".a:dirname."> newdir<".a:newdir.">)") + + let dirname= a:dirname + let newdir = a:newdir + + if dirname !~ '/$' + " apparently vim is "recognizing" that it is in the home directory and + " is removing the "/". Bad idea, so I have to put it back. + let dirname= dirname.'/' +" call Decho("adjusting dirname<".dirname.">") + endif + + if newdir !~ '/$' + " handling a file + let dirname= dirname.newdir +" call Decho("handling a file: dirname<".dirname.">") + exe "e ".dirname + + elseif newdir == './' + " refresh the directory list +" call Decho("refresh directory listing") + setlocal ma + %d + + elseif newdir == '../' + " go up one directory + let dirname= substitute(dirname,'^\(.*/\)\([^/]\+/$\)','\1','e') +" call Decho("go up one dir: dirname<".dirname.">") + + else + " go down one directory + let dirname= dirname.newdir +" call Decho("go down one dir: dirname<".dirname."> newdir<".newdir.">") + endif + +" call Dret("LocalBrowseChgDir <".dirname.">") + return dirname +endfun + +" --------------------------------------------------------------------- +" LocalBrowseRm: +fun! LocalBrowseRm(path) range +" call Dfunc("LocalBrowseRm(path<".a:path.">)") +" call Decho("firstline=".a:firstline." lastline=".a:lastline) + + " preparation for removing multiple files/directories + let ctr= a:firstline + + " remove multiple files and directories + while ctr <= a:lastline + exe ctr + + norm! 0 + let rmfile= a:path.expand("") +" call Decho("rmfile<".rmfile.">") + + if rmfile !~ '^"' && (rmfile =~ '@$' || rmfile !~ '/$') + " attempt to remove file + call inputsave() + let ok= input("Confirm deletion of file<".rmfile."> ","y") + call inputrestore() + if ok == "y" + call delete(rmfile) +" call Decho("errcode=".v:shell_error) + endif + + else + " attempt to remove directory + call inputsave() + let ok= input("Confirm deletion of directory<".rmfile."> ","y") + call inputrestore() + let rmfile= substitute(rmfile,'/$','','e') + + if ok == "y" + call system(g:netrw_local_rmdir." ".rmfile) +" call Decho("v:shell_error=".v:shell_error) + + if v:shell_error != 0 +" call Decho("2nd attempt to remove directory<".rmfile.">") + let errcode= delete(rmfile) +" call Decho("errcode=".errcode) + + if errcode != 0 + if has("unix") +" call Decho("3rd attempt to remove directory<".rmfile.">") + call system("rm ".rmfile) + if v:shell_error != 0 + echoerr "unable to remove directory<".rmfile."> -- is it empty?" + endif + else + echoerr "unable to remove directory<".rmfile."> -- is it empty?" + endif + endif + endif + endif + endif + + let ctr= ctr + 1 + endwhile + + " refresh the directory + let curline= line(".")-1 +" call Decho("refresh the directory") + call LocalBrowse(LocalBrowseChgDir(expand("%"),'./')) + exe curline + +" call Dret("LocalBrowseRm") +endfun + +" --------------------------------------------------------------------- +" LocalBrowseRename: rename a remote file or directory {{{2 +fun! LocalBrowseRename(path) +" call Dfunc("LocalBrowseRename(path<".a:path.">)") + + " preparation for removing multiple files/directories + let ctr= a:firstline + + " attempt to rename files/directories + while ctr <= a:lastline + exe "keepjumps ".ctr + + norm! 0 + let oldname= a:path.expand("") +" call Decho("oldname<".oldname.">") + + call inputsave() + let newname= input("Moving ".oldname." to : ",oldname) + call inputrestore() + + let ret= system(g:netrw_local_rename." ".oldname." ".newname) +" call Decho("executing system(".g:netrw_local_rename." ".oldname." ".newname) + + let ctr= ctr + 1 + endwhile + + " refresh the directory + let curline= line(".") + call LocalBrowse(LocalBrowseChgDir(expand("%"),'./')) + exe "keepjumps ".curline +" call Dret("LocalBrowseRename") +endfun + +" --------------------------------------------------------------------- " NetMethod: determine method of transfer {{{1 " method == 1: rcp " 2: ftp + <.netrc> @@ -1531,14 +2036,14 @@ fun!s:NetOptionSave() let s:dirkeep = getcwd() let s:gdkeep = &gd let s:twkeep = &tw - set cino = - set com = - set cpo -=aA - set nocin noai - set tw =0 + setlocal cino = + setlocal com = + setlocal cpo -=aA + setlocal nocin noai + setlocal tw =0 if has("win32") && !has("win95") let s:swfkeep= &swf - set noswf + setlocal noswf " call Decho("setting s:swfkeep to <".&swf.">") endif @@ -1595,6 +2100,8 @@ endif " --------------------------------------------------------------------- " NetSort: Piet Delport's BISort2() function, modified to take a range {{{1 fun! NetSort() range +" call Dfunc("NetSort()") + let i = a:firstline + 1 while i <= a:lastline " find insertion point via binary search @@ -1629,13 +2136,29 @@ fun! NetSort() range endif let i = i + 1 endwhile + +" call Dret("NetSort") endfun " --------------------------------------------------------------------- -" SetSort: sets up the sort based on the g:netrw_sort_sequence +" SetSort: sets up the sort based on the g:netrw_sort_sequence {{{1 +" What this function does is to compute a priority for the patterns +" in the g:netrw_sort_sequence. It applies a substitute to any +" "files" that satisfy each pattern, putting the priority / in +" front. An "*" pattern handles the default priority. fun! SetSort() " call Dfunc("SetSort() bannercnt=".g:netrw_bannercnt) - let seqlist = g:netrw_sort_sequence + if g:netrw_longlist + let seqlist = substitute(g:netrw_sort_sequence,'\$','\\%(\t\\|\$\\)','ge') + else + let seqlist = g:netrw_sort_sequence + endif + " sanity check -- insure that * appears somewhere + if seqlist == "" + let seqlist= '*' + elseif seqlist !~ '\*' + let seqlist= seqlist.',*' + endif let priority = 1 while seqlist != "" if seqlist =~ ',' diff --git a/runtime/print/ascii.ps b/runtime/print/ascii.ps new file mode 100644 --- /dev/null +++ b/runtime/print/ascii.ps @@ -0,0 +1,22 @@ +%!PS-Adobe-3.0 Resource-Encoding +%%Title: VIM-ascii +%%Version: 1.0 0 +%%EndComments +/VIM-ascii[ +32{/.notdef}repeat +/space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle +/parenleft /parenright /asterisk /plus /comma /minus /period /slash +/zero /one /two /three /four /five /six /seven +/eight /nine /colon /semicolon /less /equal /greater /question +/at /A /B /C /D /E /F /G +/H /I /J /K /L /M /N /O +/P /Q /R /S /T /U /V /W +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +/grave /a /b /c /d /e /f /g +/h /i /j /k /l /m /n /o +/p /q /r /s /t /u /v /w +/x /y /z /braceleft /bar /braceright /asciitilde /.notdef +128{/.notdef}repeat] +/Encoding defineresource pop +% vim:ff=unix: +%%EOF diff --git a/runtime/print/cidfont.ps b/runtime/print/cidfont.ps new file mode 100644 --- /dev/null +++ b/runtime/print/cidfont.ps @@ -0,0 +1,26 @@ +%!PS-Adobe-3.0 Resource-ProcSet +%%Title: VIM-CIDFont +%%Version: 1.0 0 +%%EndComments +% Editing of this file is NOT RECOMMENDED. You run a very good risk of causing +% all PostScript printing from VIM failing if you do. PostScript is not called +% a write-only language for nothing! +/CP currentpacking d T setpacking +/SB 256 string d +/CIDN? systemdict/composefont known d /GS? systemdict/.makeoperator known d +CIDN?{ +GS?{/vim_findresource{2 copy resourcestatus not{1 index SB cvs runlibfile}{ +pop pop}ifelse findresource}bd/vim_composefont{0 get/CIDFont vim_findresource +exch/CMap vim_findresource exch[exch]composefont pop}bd}{/vim_findresource +/findresource ld/vim_composefont{composefont pop}bd}ifelse +}{ +/vim_fontname{0 get SB cvs length dup SB exch(-)putinterval 1 add dup SB exch +dup 256 exch sub getinterval 3 -1 roll exch cvs length add SB exch 0 exch +getinterval cvn}bd/vim_composefont{vim_fontname findfont d}bd +} ifelse +/cfs{exch scalefont d}bd +/sffs{findfont 3 1 roll 1 index mul exch 2 index/FontMatrix get matrix copy +scale makefont d}bd +CP setpacking +% vim:ff=unix: +%%EOF diff --git a/runtime/print/cns_roman.ps b/runtime/print/cns_roman.ps new file mode 100644 --- /dev/null +++ b/runtime/print/cns_roman.ps @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 Resource-Encoding +%%Title: VIM-cns_roman +%%Version: 1.0 0 +%%EndComments +% Different to ASCII at code point 126 +/VIM-cns_roman[ +32{/.notdef}repeat +/space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle +/parenleft /parenright /asterisk /plus /comma /minus /period /slash +/zero /one /two /three /four /five /six /seven +/eight /nine /colon /semicolon /less /equal /greater /question +/at /A /B /C /D /E /F /G +/H /I /J /K /L /M /N /O +/P /Q /R /S /T /U /V /W +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +/grave /a /b /c /d /e /f /g +/h /i /j /k /l /m /n /o +/p /q /r /s /t /u /v /w +/x /y /z /braceleft /bar /braceright /overline /.notdef +128{/.notdef}repeat] +/Encoding defineresource pop +% vim:ff=unix: +%%EOF diff --git a/runtime/print/gb_roman.ps b/runtime/print/gb_roman.ps new file mode 100644 --- /dev/null +++ b/runtime/print/gb_roman.ps @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 Resource-Encoding +%%Title: VIM-gb_roman +%%Version: 1.0 0 +%%EndComments +% Different to ASCII at code points 36 and 126 +/VIM-gb_roman[ +32{/.notdef}repeat +/space /exclam /quotedbl /numbersign /yuan /percent /ampersand /quotesingle +/parenleft /parenright /asterisk /plus /comma /minus /period /slash +/zero /one /two /three /four /five /six /seven +/eight /nine /colon /semicolon /less /equal /greater /question +/at /A /B /C /D /E /F /G +/H /I /J /K /L /M /N /O +/P /Q /R /S /T /U /V /W +/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore +/grave /a /b /c /d /e /f /g +/h /i /j /k /l /m /n /o +/p /q /r /s /t /u /v /w +/x /y /z /braceleft /bar /braceright /overline /.notdef +128{/.notdef}repeat] +/Encoding defineresource pop +% vim:ff=unix: +%%EOF diff --git a/runtime/print/jis_roman.ps b/runtime/print/jis_roman.ps new file mode 100644 --- /dev/null +++ b/runtime/print/jis_roman.ps @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 Resource-Encoding +%%Title: VIM-jis_roman +%%Version: 1.0 0 +%%EndComments +% Different to ASCII at code points 92 and 126 +/VIM-jis_roman[ +32{/.notdef}repeat +/space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle +/parenleft /parenright /asterisk /plus /comma /minus /period /slash +/zero /one /two /three /four /five /six /seven +/eight /nine /colon /semicolon /less /equal /greater /question +/at /A /B /C /D /E /F /G +/H /I /J /K /L /M /N /O +/P /Q /R /S /T /U /V /W +/X /Y /Z /bracketleft /yen /bracketright /asciicircum /underscore +/grave /a /b /c /d /e /f /g +/h /i /j /k /l /m /n /o +/p /q /r /s /t /u /v /w +/x /y /z /braceleft /bar /braceright /overline /.notdef +128{/.notdef}repeat] +/Encoding defineresource pop +% vim:ff=unix: +%%EOF diff --git a/runtime/print/ks_roman.ps b/runtime/print/ks_roman.ps new file mode 100644 --- /dev/null +++ b/runtime/print/ks_roman.ps @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 Resource-Encoding +%%Title: VIM-ks_roman +%%Version: 1.0 0 +%%EndComments +% Different to ASCII at code points 96 and 126 +/VIM-ks_roman[ +32{/.notdef}repeat +/space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle +/parenleft /parenright /asterisk /plus /comma /minus /period /slash +/zero /one /two /three /four /five /six /seven +/eight /nine /colon /semicolon /less /equal /greater /question +/at /A /B /C /D /E /F /G +/H /I /J /K /L /M /N /O +/P /Q /R /S /T /U /V /W +/X /Y /Z /bracketleft /won /bracketright /asciicircum /underscore +/grave /a /b /c /d /e /f /g +/h /i /j /k /l /m /n /o +/p /q /r /s /t /u /v /w +/x /y /z /braceleft /bar /braceright /overline /.notdef +128{/.notdef}repeat] +/Encoding defineresource pop +% vim:ff=unix: +%%EOF diff --git a/runtime/print/prolog.ps b/runtime/print/prolog.ps --- a/runtime/print/prolog.ps +++ b/runtime/print/prolog.ps @@ -5,13 +5,15 @@ % Editing of this file is NOT RECOMMENDED. You run a very good risk of causing % all PostScript printing from VIM failing if you do. PostScript is not called % a write-only language for nothing! +/packedarray where not{userdict begin/setpacking/pop load def/currentpacking +false def end}{pop}ifelse/CP currentpacking def true setpacking /bd{bind def}bind def/ld{load def}bd/ed{exch def}bd/d/def ld /db{dict begin}bd/cde{currentdict end}bd /T true d/F false d /SO null d/sv{/SO save d}bd/re{SO restore}bd /L2 systemdict/languagelevel 2 copy known{get exec}{pop pop 1}ifelse 2 ge d -/m{moveto}bd/s{show}bd/ms{m s}bd/g{setgray}bd/r{setrgbcolor}bd/sp{showpage}bd -/gs{gsave}bd/gr{grestore}bd/cp{currentpoint}bd +/m/moveto ld/s/show ld /ms{m s}bd /g/setgray ld/r/setrgbcolor ld/sp{showpage}bd +/gs/gsave ld/gr/grestore ld/cp/currentpoint ld /ul{gs UW setlinewidth cp UO add 2 copy newpath m 3 1 roll add exch lineto stroke gr}bd /bg{gs r cp BO add 4 -2 roll rectfill gr}bd @@ -36,6 +38,7 @@ 3 -1 roll put}{pop}ifelse NFD dup/FontTy ifelse 2 copy known{2 copy get dup maxlength dict copy[/questiondown/space]{2 copy known{2 copy get 2 index/.notdef 3 -1 roll put pop exit}if pop}forall put }{pop pop}ifelse dup NFD/FontName 3 -1 roll put NFD definefont pop end}bd +CP setpacking (\004)cvn{}bd % vim:ff=unix: %%EOF diff --git a/runtime/syntax/forth.vim b/runtime/syntax/forth.vim --- a/runtime/syntax/forth.vim +++ b/runtime/syntax/forth.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: FORTH " Maintainer: Christian V. J. Brüssow -" Last Change: Son 22 Jun 2003 20:42:55 CEST +" Last Change: Di 06 Jul 2004 18:40:33 CEST " Filenames: *.fs,*.ft -" URL: http://www.cvjb.de/comp/vim/forth.vim +" URL: http://www.cvjb.de/comp/vim/forth.vim " $Id$ @@ -13,12 +13,16 @@ " Many Thanks to... " +" 2004-07-06: +" Changed "syn sync ccomment maxlines=200" line: splitted it into two separate +" lines. +" " 2003-05-10: " Andrew Gaul send me a patch for " forthOperators. " " 2003-04-03: -" Ron Aaron made updates for an +" Ron Aaron made updates for an " improved Win32Forth support. " " 2002-04-22: @@ -46,7 +50,8 @@ elseif exists("b:current_syntax") endif " Synchronization method -syn sync ccomment maxlines=200 +syn sync ccomment +syn sync maxlines=200 " I use gforth, so I set this to case ignore syn case ignore @@ -189,10 +194,10 @@ syn match forthInclude '^needs\s\+' " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_forth_syn_inits") if version < 508 - let did_forth_syn_inits = 1 - command -nargs=+ HiLink hi link + let did_forth_syn_inits = 1 + command -nargs=+ HiLink hi link else - command -nargs=+ HiLink hi def link + command -nargs=+ HiLink hi def link endif " The default methods for highlighting. Can be overriden later. diff --git a/runtime/syntax/iss.vim b/runtime/syntax/iss.vim --- a/runtime/syntax/iss.vim +++ b/runtime/syntax/iss.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Inno Setup File (iss file) and My InnoSetup extension " Maintainer: Dominique Stéphan (dominique@mggen.com) -" Last change: 2003 May 11 +" Last change: 2004 July 5 " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded @@ -25,16 +25,18 @@ syn match issURL "http[s]\=:\/\/.*$" " syn match issName "[^: ]\+:" syn match issName "Name:" -syn match issName "MinVersion:\|OnlyBelowVersion:" +syn match issName "MinVersion:\|OnlyBelowVersion:\|Languages:" syn match issName "Source:\|DestDir:\|DestName:\|CopyMode:" -syn match issName "Attribs:\|FontInstall:\|Flags:" -syn match issName "FileName:\|Parameters:\|WorkingDir:\|Comment:" +syn match issName "Attribs:\|Permissions:\|FontInstall:\|Flags:" +syn match issName "FileName:\|Parameters:\|WorkingDir:\|HotKey:\|Comment:" syn match issName "IconFilename:\|IconIndex:" syn match issName "Section:\|Key:\|String:" syn match issName "Root:\|SubKey:\|ValueType:\|ValueName:\|ValueData:" syn match issName "RunOnceId:" syn match issName "Type:" -syn match issName "Components:\|Description:\|GroupDescription\|Types:" +syn match issName "Components:\|Description:\|GroupDescription:\|Types:\|ExtraDiskSpaceRequired:" +syn match issName "StatusMsg:\|RunOnceId:\|Tasks:" +syn match issName "MessagesFile:\|LicenseFile:\|InfoBeforeFile:\|InfoAfterFile:" syn match issComment "^;.*$" @@ -48,15 +50,19 @@ syn region issString start=+"+ end=+"+ syn keyword issDirsFlags deleteafterinstall uninsalwaysuninstall uninsneveruninstall " [Files] -syn keyword issFilesCopyMode normal onlyifdoesntexist alwaysoverwrite alwaysskipifsameorolder +syn keyword issFilesCopyMode normal onlyifdoesntexist alwaysoverwrite alwaysskipifsameorolder dontcopy syn keyword issFilesAttribs readonly hidden system -syn keyword issFilesFlags comparetimestampalso confirmoverwrite deleteafterinstall -syn keyword issFilesFlags external fontisnttruetype isreadme overwritereadonly -syn keyword issFilesFlags regserver regtypelib restartreplace -syn keyword issFilesFlags sharedfile skipifsourcedoesntexist uninsneveruninstall +syn keyword issFilesPermissions full modify readexec +syn keyword issFilesFlags allowunsafefiles comparetimestampalso confirmoverwrite deleteafterinstall +syn keyword issFilesFlags dontcopy dontverifychecksum external fontisnttruetype ignoreversion +syn keyword issFilesFlags isreadme onlyifdestfileexists onlyifdoesntexist overwritereadonly +syn keyword issFilesFlags promptifolder recursesubdirs regserver regtypelib restartreplace +syn keyword issFilesFlags sharedfile skipifsourcedoesntexist sortfilesbyextension touch +syn keyword issFilesFlags uninsremovereadonly uninsrestartdelete uninsneveruninstall " [Icons] -syn keyword issIconsFlags createonlyiffileexists runminimized uninsneveruninstall useapppaths +syn keyword issIconsFlags closeonexit createonlyiffileexists dontcloseonexit +syn keyword issIconsFlags runmaximized runminimized uninsneveruninstall useapppaths " [INI] syn keyword issINIFlags createkeyifdoesntexist uninsdeleteentry uninsdeletesection uninsdeletesectionifempty @@ -64,22 +70,27 @@ syn keyword issINIFlags createkeyifdoesn " [Registry] syn keyword issRegRootKey HKCR HKCU HKLM HKU HKCC syn keyword issRegValueType none string expandsz multisz dword binary -syn keyword issRegFlags createvalueifdoesntexist deletekey deletevalue preservestringtype -syn keyword issRegFlags uninsclearvalue uninsdeletekey uninsdeletekeyifempty uninsdeletevalue +syn keyword issRegFlags createvalueifdoesntexist deletekey deletevalue dontcreatekey +syn keyword issRegFlags preservestringtype noerror uninsclearvalue +syn keyword issRegFlags uninsdeletekey uninsdeletekeyifempty uninsdeletevalue " [Run] and [UninstallRun] -syn keyword issRunFlags nowait shellexec skipifdoesntexist runminimized waituntilidle -syn keyword issRunFlags postinstall unchecked showcheckbox +syn keyword issRunFlags hidewizard nowait postinstall runhidden runmaximized +syn keyword issRunFlags runminimized shellexec skipifdoesntexist skipifnotsilent +syn keyword issRunFlags skipifsilent unchecked waituntilidle " [Types] syn keyword issTypesFlags iscustom " [Components] -syn keyword issComponentsFlags fixed restart disablenouninstallwarning +syn keyword issComponentsFlags dontinheritcheck exclusive fixed restart disablenouninstallwarning " [UninstallDelete] and [InstallDelete] syn keyword issInstallDeleteType files filesandordirs dirifempty +" [Tasks] +syn keyword issTasksFlags checkedonce dontinheritcheck exclusive restart unchecked + " Define the default highlighting. " For version 5.7 and earlier: only when not done already @@ -105,6 +116,7 @@ if version >= 508 || !exists("did_iss_sy HiLink issDirsFlags Keyword HiLink issFilesCopyMode Keyword HiLink issFilesAttribs Keyword + HiLink issFilesPermissions Keyword HiLink issFilesFlags Keyword HiLink issIconsFlags Keyword HiLink issINIFlags Keyword @@ -115,6 +127,7 @@ if version >= 508 || !exists("did_iss_sy HiLink issTypesFlags Keyword HiLink issComponentsFlags Keyword HiLink issInstallDeleteType Keyword + HiLink issTasksFlags Keyword delcommand HiLink diff --git a/runtime/syntax/netrwlist.vim b/runtime/syntax/netrwlist.vim --- a/runtime/syntax/netrwlist.vim +++ b/runtime/syntax/netrwlist.vim @@ -1,6 +1,6 @@ " Language : Netrw Remote-Directory Listing Syntax " Maintainer : Charles E. Campbell, Jr. -" Last change: Jun 25, 2004 +" Last change: Jul 06, 2004 " Version : 2 " Syntax Clearing: {{{1 @@ -11,18 +11,18 @@ elseif exists("b:current_syntax") endif " Directory List Syntax Highlighting: {{{1 -syn match netrwDir "^.*/$" contains=netrwClassify -syn match netrwClassify "[*=|@/]$" -syn match netrwSlash contained "/" -syn match netrwSymLink "^.*@$" contains=netrwClassify -syn match netrwComment '".*$' contains=netrwHide,netrwSortBy,netrwSortSeq +syn match netrwDir "^.*/\%(\t\|$\)" contains=netrwClassify +syn match netrwClassify "[*=|@/]\%(\t\|$\)" +syn match netrwSymLink "^.*@\%(\t\|$\)" contains=netrwClassify +syn match netrwComment '".*\%(\t\|$\)' contains=netrwHide,netrwSortBy,netrwSortSeq syn match netrwHide '^"\s*Hiding:' skipwhite nextgroup=netrwHidePat -syn match netrwHidePat contained "[^,]\+" skipwhite nextgroup=netrwHideSep -syn match netrwHideSep contained transparent "," skipwhite nextgroup=netrwHidePat -syn match netrwSortBy contained transparent "Sorted by" skipwhite nextgroup=netrwList -syn match netrwSortSeq contained transparent "Sort sequence:" skipwhite nextgroup=netrwList -syn match netrwList contained ".*$" contains=netrwComma -syn match netrwComma contained "," +syn match netrwSlash contained "/" +syn match netrwHidePat contained "[^,]\+" skipwhite nextgroup=netrwHideSep +syn match netrwHideSep contained transparent "," skipwhite nextgroup=netrwHidePat +syn match netrwSortBy contained transparent "Sorted by" skipwhite nextgroup=netrwList +syn match netrwSortSeq contained transparent "Sort sequence:" skipwhite nextgroup=netrwList +syn match netrwList contained ".*$" contains=netrwComma +syn match netrwComma contained "," " Highlighting Links: {{{1 if !exists("did_drchip_dbg_syntax") diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: Vim 6.3 script " Maintainer: Dr. Charles E. Campbell, Jr. -" Last Change: Jul 01, 2004 -" Version: 6.3-05 +" Last Change: Jul 09, 2004 +" Version: 6.3-07 " Automatically generated keyword lists: {{{1 " Quit when a syntax file was already loaded {{{2 @@ -106,7 +106,7 @@ syn keyword vimAugroupKey contained aug[ " Functions : Tag is provided for those who wish to highlight tagged functions {{{2 " ========= -syn cluster vimFuncList contains=vimFuncKey,Tag,vimFuncSID +syn cluster vimFuncList contains=vimCommand,vimFuncKey,Tag,vimFuncSID syn cluster vimFuncBodyList contains=vimIsCommand,vimFunction,vimFunctionError,vimFuncBody,vimLineComment,vimSpecFile,vimOper,vimNumber,vimComment,vimString,vimSubst,vimMark,vimRegister,vimAddress,vimFilter,vimCmplxRepeat,vimComment,vimLet,vimSet,vimAutoCmd,vimRegion,vimSynLine,vimNotation,vimCtrlChar,vimFuncVar,vimContinue if !exists("g:vimsyntax_noerror") syn match vimFunctionError "\\)\=\I\i*\ze\s*(" contains=vimUserFunc,vimFuncName,vimCommand,vimNotFunc +syn match vimFunc "\%([sS]:\|<[sS][iI][dD]>\)\=\I\i*\ze\s*(" contains=vimFuncName,vimUserFunc,vimCommand,vimNotFunc,vimExecute syn match vimUserFunc contained "\%([sS]:\|<[sS][iI][dD]>\)\i\+\|\<\u\i*\>\|\" contains=vimNotation,vimCommand syn match vimNotFunc contained "\<[aiAIrR](" @@ -504,6 +503,16 @@ if (has("tcl") || g:vimembedscript) && f syn region vimTclRegion matchgroup=vimScriptDelim start=+tc[l]\=\s*<<\s*$+ end=+\.$+ contains=@vimTclScript endif +" [-- mzscheme --] {{{3 +if (has("mzscheme") || g:vimembedscript) && filereadable(expand(":p:h")."/scheme.vim") + unlet! b:current_syntax + let iskKeep= &isk + syn include @vimMzSchemeScript :p:h/scheme.vim + let &isk= iskKeep + syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimMzSchemeScript + syn region vimMzSchemeRegion matchgroup=vimScriptDelim start=+mz\%[scheme]\s*<<\s*$+ end=+\.$+ contains=@vimMzSchemeScript +endif + " Synchronize (speed) {{{2 "============ if exists("g:vim_minlines") @@ -531,7 +540,7 @@ if !exists("g:vimsyntax_noerror") hi def link vimErrSetting vimError hi def link vimFTError vimError hi def link vimFunctionError vimError - hi def link VimFunc vimError + hi def link vimFunc vimError hi def link vimHiAttribList vimError hi def link vimHiCtermError vimError hi def link vimHiKeyError vimError diff --git a/src/auto/config.mk b/src/auto/config.mk new file mode 100644 --- /dev/null +++ b/src/auto/config.mk @@ -0,0 +1,5 @@ +the first targets to make vim are: scratch config myself +srcdir = . +VIMNAME = vim +EXNAME = ex +VIEWNAME = view diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -370,6 +370,7 @@ static void f_substitute __ARGS((VAR arg static void f_tempname __ARGS((VAR argvars, VAR retvar)); static void f_tolower __ARGS((VAR argvars, VAR retvar)); static void f_toupper __ARGS((VAR argvars, VAR retvar)); +static void f_tr __ARGS((VAR argvars, VAR retvar)); static void f_type __ARGS((VAR argvars, VAR retvar)); static void f_virtcol __ARGS((VAR argvars, VAR retvar)); static void f_visualmode __ARGS((VAR argvars, VAR retvar)); @@ -2923,6 +2924,7 @@ static struct fst {"tempname", 0, 0, f_tempname}, {"tolower", 1, 1, f_tolower}, {"toupper", 1, 1, f_toupper}, + {"tr", 3, 3, f_tr}, {"type", 1, 1, f_type}, {"virtcol", 1, 1, f_virtcol}, {"visualmode", 0, 1, f_visualmode}, @@ -7438,6 +7440,122 @@ f_toupper(argvars, retvar) } /* + * "tr(string, fromstr, tostr)" function + */ + static void +f_tr(argvars, retvar) + VAR argvars; + VAR retvar; +{ + char_u *instr; + char_u *fromstr; + char_u *tostr; + char_u *p; +#ifdef FEAT_MBYTE + int inlen; + int fromlen; + int tolen; + int idx; + char_u *cpstr; + int cplen; + int first = TRUE; +#endif + char_u buf[NUMBUFLEN]; + char_u buf2[NUMBUFLEN]; + garray_T ga; + + instr = get_var_string(&argvars[0]); + fromstr = get_var_string_buf(&argvars[1], buf); + tostr = get_var_string_buf(&argvars[2], buf2); + + /* Default return value: empty string. */ + retvar->var_type = VAR_STRING; + retvar->var_val.var_string = NULL; + ga_init2(&ga, (int)sizeof(char), 80); + +#ifdef FEAT_MBYTE + if (!has_mbyte) +#endif + /* not multi-byte: fromstr and tostr must be the same length */ + if (STRLEN(fromstr) != STRLEN(tostr)) + { +error: + EMSG2(_(e_invarg2), fromstr); + ga_clear(&ga); + return; + } + + /* fromstr and tostr have to contain the same number of chars */ + while (*instr != NUL) + { +#ifdef FEAT_MBYTE + if (has_mbyte) + { + inlen = mb_ptr2len_check(instr); + cpstr = instr; + cplen = inlen; + idx = 0; + for (p = fromstr; *p != NUL; p += fromlen) + { + fromlen = mb_ptr2len_check(p); + if (fromlen == inlen && STRNCMP(instr, p, inlen) == 0) + { + for (p = tostr; *p != NUL; p += tolen) + { + tolen = mb_ptr2len_check(p); + if (idx-- == 0) + { + cplen = tolen; + cpstr = p; + break; + } + } + if (*p == NUL) /* tostr is shorter than fromstr */ + goto error; + break; + } + ++idx; + } + + if (first && cpstr == instr) + { + /* Check that fromstr and tostr have the same number of + * (multi-byte) characters. Done only once when a character + * of instr doesn't appear in fromstr. */ + first = FALSE; + for (p = tostr; *p != NUL; p += tolen) + { + tolen = mb_ptr2len_check(p); + --idx; + } + if (idx != 0) + goto error; + } + + ga_grow(&ga, cplen); + mch_memmove(ga.ga_data + ga.ga_len, cpstr, (size_t)cplen); + ga.ga_len += cplen; + ga.ga_room -= cplen; + + instr += inlen; + } + else +#endif + { + /* When not using multi-byte chars we can do it faster. */ + p = vim_strchr(fromstr, *instr); + if (p != NULL) + ga_append(&ga, tostr[p - fromstr]); + else + ga_append(&ga, *instr); + ++instr; + } + } + + retvar->var_val.var_string = ga.ga_data; +} + +/* * "type(expr)" function */ static void diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3738,6 +3738,7 @@ do_sub(eap) unsigned len, needed_len; long nmatch_tl = 0; /* nr of lines matched below lnum */ int do_again; /* do it again after joining lines */ + int skip_match = FALSE; /* * The new text is build up step by step, to avoid too much @@ -3822,7 +3823,12 @@ do_sub(eap) && regmatch.endpos[0].lnum == 0 && matchcol == regmatch.endpos[0].col) { - ++matchcol; /* search for a match at next column */ + if (sub_firstline[matchcol] == NUL) + /* We already were at the end of the line. Don't look + * for a match in this line again. */ + skip_match = TRUE; + else + ++matchcol; /* search for a match at next column */ goto skip; } @@ -4114,9 +4120,12 @@ skip: /* We already know that we did the last subst when we are at * the end of the line, except that a pattern like * "bar\|\nfoo" may match at the NUL. */ - lastone = ((sub_firstline[matchcol] == NUL && nmatch <= 1 - && !re_multiline(regmatch.regprog)) - || got_int || got_quit || !(do_all || do_again)); + lastone = (skip_match + || got_int + || got_quit + || !(do_all || do_again) + || (sub_firstline[matchcol] == NUL && nmatch <= 1 + && !re_multiline(regmatch.regprog))); nmatch = -1; /* diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3731,11 +3731,19 @@ hardcopy_line(psettings, page_line, ppos * Adobe technote 5003, 9th February 1996 * 6. Adobe Font Metrics File Format Specification, Version 4.1, * Adobe Technote 5007, 7th October 1998 + * 7. Adobe CMap and CIDFont Files Specification, Version 1.0, + * Adobe Technote 5014, 8th October 1996 + * 8. Adobe CJKV Character Collections and CMaps for CID-Keyed Fonts, + * Adoboe Technote 5094, 8th September, 2001 + * 9. CJKV Information Processing, 2nd Edition, + * O'Reilly, 2002, ISBN 1-56592-224-7 * * Some of these documents can be found in PDF form on Adobe's web site - * http://www.adobe.com */ +#define NUM_ELEMENTS(arr) (sizeof(arr)/sizeof((arr)[0])) + #define PRT_PS_DEFAULT_DPI (72) /* Default user space resolution */ #define PRT_PS_DEFAULT_FONTSIZE (10) #define PRT_PS_DEFAULT_BUFFER_SIZE (80) @@ -3783,7 +3791,8 @@ struct prt_ps_font_S #define PRT_PS_FONT_OBLIQUE (2) #define PRT_PS_FONT_BOLDOBLIQUE (3) -static struct prt_ps_font_S prt_ps_font = +/* Standard font metrics for Courier family */ +static struct prt_ps_font_S prt_ps_courier_font = { 600, -100, 50, @@ -3791,6 +3800,218 @@ static struct prt_ps_font_S prt_ps_font {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"} }; +/* Generic font metrics for multi-byte fonts */ +static struct prt_ps_font_S prt_ps_mb_font = +{ + 1000, + -100, 50, + -250, 805, + {NULL, NULL, NULL, NULL} +}; + +/* Pointer to current font set being used */ +static struct prt_ps_font_S* prt_ps_font; + +/* Structures to map user named encoding and mapping to PS equivalents for + * building CID font name */ +struct prt_ps_encoding_S +{ + char_u *encoding; + char_u *cmap_encoding; + int needs_charset; +}; + +struct prt_ps_charset_S +{ + char *charset; + char *cmap_charset; + int has_charset; +}; + +#define CS_JIS_C_1978 (0x01) +#define CS_JIS_X_1983 (0x02) +#define CS_JIS_X_1990 (0x04) +#define CS_NEC (0x08) +#define CS_MSWINDOWS (0x10) +#define CS_CP932 (0x20) +#define CS_KANJITALK6 (0x40) +#define CS_KANJITALK7 (0x80) + +/* Japanese encodings and charsets */ +static struct prt_ps_encoding_S j_encodings[] = +{ + {"iso-2022-jp", NULL, (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990| + CS_NEC)}, + {"euc-jp", "EUC", (CS_JIS_C_1978|CS_JIS_X_1983|CS_JIS_X_1990)}, + {"sjis", "RKSJ", (CS_JIS_C_1978|CS_JIS_X_1983|CS_MSWINDOWS| + CS_KANJITALK6|CS_KANJITALK7)}, + {"cp932", "RKSJ", CS_JIS_X_1983}, + {"ucs-2", "UCS2", CS_JIS_X_1990}, + {"utf-8", "UTF8" , CS_JIS_X_1990} +}; +static struct prt_ps_charset_S j_charsets[] = +{ + {"JIS_C_1978", "78", CS_JIS_C_1978}, + {"JIS_X_1983", NULL, CS_JIS_X_1983}, + {"JIS_X_1990", "Hojo", CS_JIS_X_1990}, + {"NEC", "Ext", CS_NEC}, + {"MSWINDOWS", "90ms", CS_MSWINDOWS}, + {"CP932", "90ms", CS_JIS_X_1983}, + {"KANJITALK6", "83pv", CS_KANJITALK6}, + {"KANJITALK7", "90pv", CS_KANJITALK7} +}; + +#define CS_GB_2312_80 (0x01) +#define CS_GBT_12345_90 (0x02) +#define CS_GBK2K (0x04) +#define CS_SC_MAC (0x08) +#define CS_GBT_90_MAC (0x10) +#define CS_GBK (0x20) +#define CS_SC_ISO10646 (0x40) + +/* Simplified Chinese encodings and charsets */ +static struct prt_ps_encoding_S sc_encodings[] = +{ + {"iso-2022", NULL, (CS_GB_2312_80|CS_GBT_12345_90)}, + {"gb18030", NULL, CS_GBK2K}, + {"euc-cn", "EUC", (CS_GB_2312_80|CS_GBT_12345_90|CS_SC_MAC| + CS_GBT_90_MAC)}, + {"gbk", "EUC", CS_GBK}, + {"ucs-2", "UCS2", CS_SC_ISO10646}, + {"utf-8", "UTF8", CS_SC_ISO10646} +}; +static struct prt_ps_charset_S sc_charsets[] = +{ + {"GB_2312-80", "GB", CS_GB_2312_80}, + {"GBT_12345-90","GBT", CS_GBT_12345_90}, + {"MAC", "GBpc", CS_SC_MAC}, + {"GBT-90_MAC", "GBTpc", CS_GBT_90_MAC}, + {"GBK", "GBK", CS_GBK}, + {"GB18030", "GBK2K", CS_GBK2K}, + {"ISO10646", "UniGB", CS_SC_ISO10646} +}; + +#define CS_CNS_PLANE_1 (0x01) +#define CS_CNS_PLANE_2 (0x02) +#define CS_CNS_PLANE_1_2 (0x04) +#define CS_B5 (0x08) +#define CS_ETEN (0x10) +#define CS_HK_GCCS (0x20) +#define CS_HK_SCS (0x40) +#define CS_HK_SCS_ETEN (0x80) +#define CS_MTHKL (0x100) +#define CS_MTHKS (0x200) +#define CS_DLHKL (0x400) +#define CS_DLHKS (0x800) +#define CS_TC_ISO10646 (0x1000) + +/* Traditional Chinese encodings and charsets */ +static struct prt_ps_encoding_S tc_encodings[] = +{ + {"iso-2022", NULL, (CS_CNS_PLANE_1|CS_CNS_PLANE_2)}, + {"euc-tw", "EUC", CS_CNS_PLANE_1_2}, + {"big5", "B5", (CS_B5|CS_ETEN|CS_HK_GCCS|CS_HK_SCS| + CS_HK_SCS_ETEN|CS_MTHKL|CS_MTHKS|CS_DLHKL| + CS_DLHKS)}, + {"cp950", "B5", CS_B5}, + {"ucs-2", "UCS2", CS_TC_ISO10646}, + {"utf-8", "UTF8", CS_TC_ISO10646}, + {"utf-16", "UTF16", CS_TC_ISO10646}, + {"utf-32", "UTF32", CS_TC_ISO10646} +}; +static struct prt_ps_charset_S tc_charsets[] = +{ + {"CNS_1992_1", "CNS1", CS_CNS_PLANE_1}, + {"CNS_1992_2", "CNS2", CS_CNS_PLANE_2}, + {"CNS_1993", "CNS", CS_CNS_PLANE_1_2}, + {"BIG5", NULL, CS_B5}, + {"CP950", NULL, CS_B5}, + {"ETEN", "ETen", CS_ETEN}, + {"HK_GCCS", "HKgccs", CS_HK_GCCS}, + {"SCS", "HKscs", CS_HK_SCS}, + {"SCS_ETEN", "ETHK", CS_HK_SCS_ETEN}, + {"MTHKL", "HKm471", CS_MTHKL}, + {"MTHKS", "HKm314", CS_MTHKS}, + {"DLHKL", "HKdla", CS_DLHKL}, + {"DLHKS", "HKdlb", CS_DLHKS}, + {"ISO10646", "UniCNS", CS_TC_ISO10646} +}; + +#define CS_KR_X_1992 (0x01) +#define CS_KR_MAC (0x02) +#define CS_KR_X_1992_MS (0x04) +#define CS_KR_ISO10646 (0x08) + +/* Korean encodings and charsets */ +static struct prt_ps_encoding_S k_encodings[] = +{ + {"iso-2022-kr", NULL, CS_KR_X_1992}, + {"euc-kr", "EUC", (CS_KR_X_1992|CS_KR_MAC)}, + {"johab", "Johab", CS_KR_X_1992}, + {"cp1361", "Johab", CS_KR_X_1992}, + {"uhc", "UHC", CS_KR_X_1992_MS}, + {"cp949", "UHC", CS_KR_X_1992_MS}, + {"ucs-2", "UCS2", CS_KR_ISO10646}, + {"utf-8", "UTF8", CS_KR_ISO10646} +}; +static struct prt_ps_charset_S k_charsets[] = +{ + {"KS_X_1992", "KSC", CS_KR_X_1992}, + {"CP1361", "KSC", CS_KR_X_1992}, + {"MAC", "KSCpc", CS_KR_MAC}, + {"MSWINDOWS", "KSCms", CS_KR_X_1992_MS}, + {"CP949", "KSCms", CS_KR_X_1992_MS}, + {"WANSUNG", "KSCms", CS_KR_X_1992_MS}, + {"ISO10646", "UniKS", CS_KR_ISO10646} +}; + +/* Collections of encodings and charsets for multi-byte printing */ +struct prt_ps_mbfont_S +{ + int num_encodings; + struct prt_ps_encoding_S *encodings; + int num_charsets; + struct prt_ps_charset_S *charsets; + char *ascii_enc; + char *defcs; +}; + +static struct prt_ps_mbfont_S prt_ps_mbfonts[] = +{ + { + NUM_ELEMENTS(j_encodings), + j_encodings, + NUM_ELEMENTS(j_charsets), + j_charsets, + "jis_roman", + "JIS_X_1983" + }, + { + NUM_ELEMENTS(sc_encodings), + sc_encodings, + NUM_ELEMENTS(sc_charsets), + sc_charsets, + "gb_roman", + "GB_2312-80" + }, + { + NUM_ELEMENTS(tc_encodings), + tc_encodings, + NUM_ELEMENTS(tc_charsets), + tc_charsets, + "cns_roman", + "BIG5" + }, + { + NUM_ELEMENTS(k_encodings), + k_encodings, + NUM_ELEMENTS(k_charsets), + k_charsets, + "ks_roman", + "KS_X_1992" + } +}; + struct prt_ps_resource_S { char_u name[64]; @@ -3803,25 +4024,29 @@ struct prt_ps_resource_S /* Types of PS resource file currently used */ #define PRT_RESOURCE_TYPE_PROCSET (0) #define PRT_RESOURCE_TYPE_ENCODING (1) +#define PRT_RESOURCE_TYPE_CMAP (2) /* The PS prolog file version number has to match - if the prolog file is * updated, increment the number in the file and here. Version checking was * added as of VIM 6.2. + * The CID prolog file version number behaves as per PS prolog. * Table of VIM and prolog versions: * - * VIM Prolog + * VIM Prolog CIDProlog * 6.2 1.3 - * 7.0 1.4 + * 7.0 1.4 1.0 */ #define PRT_PROLOG_VERSION ((char_u *)"1.4") +#define PRT_CID_PROLOG_VERSION ((char_u *)"1.0") /* String versions of PS resource types - indexed by constants above so don't * re-order! */ -static char *resource_types[] = +static char *prt_resource_types[] = { "procset", - "encoding" + "encoding", + "cmap" }; /* Strings to look for in a PS resource file */ @@ -3829,8 +4054,44 @@ static char *resource_types[] = #define PRT_RESOURCE_RESOURCE "Resource-" #define PRT_RESOURCE_PROCSET "ProcSet" #define PRT_RESOURCE_ENCODING "Encoding" -#define PRT_RESOURCE_TITLE "%%Title:" -#define PRT_RESOURCE_VERSION "%%Version:" +#define PRT_RESOURCE_CMAP "CMap" + + +/* Data for table based DSC comment recognition, easy to extend if VIM needs to + * read more comments. */ +#define PRT_DSC_MISC_TYPE (-1) +#define PRT_DSC_TITLE_TYPE (1) +#define PRT_DSC_VERSION_TYPE (2) +#define PRT_DSC_ENDCOMMENTS_TYPE (3) + +#define PRT_DSC_TITLE "%%Title:" +#define PRT_DSC_VERSION "%%Version:" +#define PRT_DSC_ENDCOMMENTS "%%EndComments:" + +struct prt_dsc_comment_S +{ + char_u *string; + int len; + int type; +}; + +struct prt_dsc_line_S +{ + int type; + char_u *string; + int len; +}; + + +#define SIZEOF_CSTR(s) (sizeof(s) - 1) +struct prt_dsc_comment_S prt_dsc_table[] = +{ + {PRT_DSC_TITLE, SIZEOF_CSTR(PRT_DSC_TITLE), PRT_DSC_TITLE_TYPE}, + {PRT_DSC_VERSION, SIZEOF_CSTR(PRT_DSC_VERSION), + PRT_DSC_VERSION_TYPE}, + {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS), + PRT_DSC_ENDCOMMENTS_TYPE} +}; static void prt_write_file_raw_len __ARGS((char_u *buffer, int bytes)); static void prt_write_file __ARGS((char_u *buffer)); @@ -3854,13 +4115,24 @@ static void prt_dsc_text __ARGS((char *c static void prt_dsc_ints __ARGS((char *comment, int count, int *ints)); static void prt_dsc_requirements __ARGS((int duplex, int tumble, int collate, int color, int num_copies)); static void prt_dsc_docmedia __ARGS((char *paper_name, double width, double height, double weight, char *colour, char *type)); -static void prt_dsc_resources __ARGS((char *comment, char *type, int count, char **strings)); +static void prt_dsc_resources __ARGS((char *comment, char *type, char *strings)); +static void prt_dsc_font_resource __ARGS((char *resource, struct prt_ps_font_S *ps_font)); static float to_device_units __ARGS((int idx, double physsize, int def_number)); static void prt_page_margins __ARGS((double width, double height, double *left, double *right, double *top, double *bottom)); static void prt_font_metrics __ARGS((int font_scale)); static int prt_get_cpl __ARGS((void)); static int prt_get_lpp __ARGS((void)); static int prt_add_resource __ARGS((struct prt_ps_resource_S *resource)); +static int prt_resfile_next_line __ARGS((void)); +static int prt_resfile_strncmp __ARGS((int offset, char *string, int len)); +static int prt_resfile_skip_nonws __ARGS((int offset)); +static int prt_resfile_skip_ws __ARGS((int offset)); +static int prt_next_dsc __ARGS((struct prt_dsc_line_S *p_dsc_line)); +#ifdef FEAT_MBYTE +static void prt_def_cidfont __ARGS((char *new_name, int height, char *cidfont)); +static int prt_match_encoding __ARGS((char *p_encoding, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_encoding_S **pp_mbenc)); +static int prt_match_charset __ARGS((char *p_charset, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_charset_S **pp_mbchar)); +#endif /* * Variables for the output PostScript file. @@ -3905,8 +4177,9 @@ static int prt_do_bgcol; static int prt_bgcol; static int prt_new_bgcol; static int prt_attribute_change; -static int prt_text_count; +static float prt_text_run; static int prt_page_num; +static int prt_bufsiz; /* * Variables controlling physical printing. @@ -3927,6 +4200,15 @@ static garray_T prt_ps_buffer; # ifdef FEAT_MBYTE static int prt_do_conv; static vimconv_T prt_conv; + +static int prt_out_mbyte; +static int prt_custom_cmap; +static char prt_cmap[80]; +static int prt_use_courier; +static int prt_in_ascii; +static int prt_half_width; +static char *prt_ascii_encoding; +static char_u prt_hexchar[] = "0123456789abcdef"; # endif static void @@ -3995,7 +4277,7 @@ prt_write_boolean(b) } /* - * Write a line to define the font. + * Write PostScript to re-encode and define the font. */ static void prt_def_font(new_name, encoding, height, font) @@ -4004,13 +4286,51 @@ prt_def_font(new_name, encoding, height, int height; char *font; { - sprintf((char *)prt_line_buffer, "/_%s /VIM-%s /%s ref\n", new_name, encoding, font); + sprintf((char *)prt_line_buffer, "/_%s /VIM-%s /%s ref\n", + new_name, encoding, font); prt_write_file(prt_line_buffer); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + sprintf((char *)prt_line_buffer, "/%s %d %f /_%s sffs\n", + new_name, height, 500./prt_ps_courier_font.wx, new_name); + else +#endif sprintf((char *)prt_line_buffer, "/%s %d /_%s ffs\n", new_name, height, new_name); prt_write_file(prt_line_buffer); } +#ifdef FEAT_MBYTE +/* + * Write a line to define the CID font. + */ + static void +prt_def_cidfont(new_name, height, cidfont) + char *new_name; + int height; + char *cidfont; +{ + sprintf((char *)prt_line_buffer, "/_%s /%s[/%s] vim_composefont\n", + new_name, prt_cmap, cidfont); + prt_write_file(prt_line_buffer); + sprintf((char *)prt_line_buffer, "/%s %d /_%s ffs\n", new_name, height, + new_name); + prt_write_file(prt_line_buffer); +} + +/* + * Write a line to define a duplicate of a CID font + */ + static void +prt_dup_cidfont(original_name, new_name) + char *original_name; + char *new_name; +{ + sprintf((char *)prt_line_buffer, "/%s %s d\n", new_name, original_name); + prt_write_file(prt_line_buffer); +} +#endif + /* * Convert a real value into an integer and fractional part as integers, with * the fractional part being in the range [0,10^precision). The fractional part @@ -4110,7 +4430,7 @@ prt_flush_buffer() } /* Size of rect of background color on which text is printed */ - prt_write_real(prt_text_count * prt_char_width, 2); + prt_write_real(prt_text_run, 2); prt_write_real(prt_line_height, 2); /* Lastly add the color of the background */ @@ -4135,17 +4455,26 @@ prt_flush_buffer() prt_do_moveto = FALSE; } - /* Underlining is easy - just need the number of characters to - * print. */ - prt_write_real(prt_text_count * prt_char_width, 2); + /* Underline length of text run */ + prt_write_real(prt_text_run, 2); prt_write_string("ul\n"); } /* Draw the text * Note: we write text out raw - EBCDIC conversion is handled in the * PostScript world via the font encoding vector. */ - prt_write_string("("); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + prt_write_string("<"); + else +#endif + prt_write_string("("); prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len); - prt_write_string(")"); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + prt_write_string(">"); + else +#endif + prt_write_string(")"); /* Add a moveto if need be and use the appropriate show procedure */ if (prt_do_moveto) { @@ -4159,7 +4488,7 @@ prt_flush_buffer() prt_write_string("s\n"); ga_clear(&prt_ps_buffer); - ga_init2(&prt_ps_buffer, (int)sizeof(char), PRT_PS_DEFAULT_BUFFER_SIZE); + ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz); } } @@ -4198,17 +4527,155 @@ prt_find_resource(name, resource) #define PSLF (0x0a) #define PSCR (0x0d) -/* Very simple hand crafted parser to get the type, title, and version number of - * a PS resource file so the file details can be added to the DSC header - * comments. */ +/* Static buffer to read initial comments in a resource file, some can have a + * couple of KB of comments! */ +#define PRT_FILE_BUFFER_LEN (2048) +struct prt_resfile_buffer_S +{ + char_u buffer[PRT_FILE_BUFFER_LEN]; + int len; + int line_start; + int line_end; +}; + +static struct prt_resfile_buffer_S prt_resfile; + + static int +prt_resfile_next_line() +{ + int index; + + /* Move to start of next line and then find end of line */ + index = prt_resfile.line_end + 1; + while (index < prt_resfile.len) + { + if (prt_resfile.buffer[index] != PSLF && prt_resfile.buffer[index] + != PSCR) + break; + index++; + } + prt_resfile.line_start = index; + + while (index < prt_resfile.len) + { + if (prt_resfile.buffer[index] == PSLF || prt_resfile.buffer[index] + == PSCR) + break; + index++; + } + prt_resfile.line_end = index; + + return (index < prt_resfile.len); +} + + static int +prt_resfile_strncmp(offset, string, len) + int offset; + char *string; + int len; +{ + /* Force not equal if string is longer than remainder of line */ + if (len > (prt_resfile.line_end - (prt_resfile.line_start + offset))) + return 1; + + return STRNCMP(&prt_resfile.buffer[prt_resfile.line_start + offset], + string, len); +} + + static int +prt_resfile_skip_nonws(offset) + int offset; +{ + int index; + + index = prt_resfile.line_start + offset; + while (index < prt_resfile.line_end) + { + if (isspace(prt_resfile.buffer[index])) + return index - prt_resfile.line_start; + index++; + } + return -1; +} + + static int +prt_resfile_skip_ws(offset) + int offset; +{ + int index; + + index = prt_resfile.line_start + offset; + while (index < prt_resfile.line_end) + { + if (!isspace(prt_resfile.buffer[index])) + return index - prt_resfile.line_start; + index++; + } + return -1; +} + +/* prt_next_dsc() - returns detail on next DSC comment line found. Returns true + * if a DSC comment is found, else false */ + static int +prt_next_dsc(p_dsc_line) + struct prt_dsc_line_S *p_dsc_line; +{ + int comment; + int offset; + + /* Move to start of next line */ + if (!prt_resfile_next_line()) + return FALSE; + + /* DSC comments always start %% */ + if (prt_resfile_strncmp(0, "%%", 2) != 0) + return FALSE; + + /* Find type of DSC comment */ + for (comment = 0; comment < NUM_ELEMENTS(prt_dsc_table); comment++) + if (prt_resfile_strncmp(0, prt_dsc_table[comment].string, + prt_dsc_table[comment].len) == 0) + break; + + if (comment != NUM_ELEMENTS(prt_dsc_table)) + { + /* Return type of comment */ + p_dsc_line->type = prt_dsc_table[comment].type; + offset = prt_dsc_table[comment].len; + } + else + { + /* Unrecognised DSC comment, skip to ws after comment leader */ + p_dsc_line->type = PRT_DSC_MISC_TYPE; + offset = prt_resfile_skip_nonws(0); + if (offset == -1) + return FALSE; + } + + /* Skip ws to comment value */ + offset = prt_resfile_skip_ws(offset); + if (offset == -1) + return FALSE; + + p_dsc_line->string = &prt_resfile.buffer[prt_resfile.line_start + offset]; + p_dsc_line->len = prt_resfile.line_end - (prt_resfile.line_start + offset); + + return TRUE; +} + +/* Improved hand crafted parser to get the type, title, and version number of a + * PS resource file so the file details can be added to the DSC header comments. + */ static int prt_open_resource(resource) struct prt_ps_resource_S *resource; { + int offset; + int seen_all; + int seen_title; + int seen_version; FILE *fd_resource; - char_u buffer[128]; - char_u *ch = buffer; - char_u *ch2; + struct prt_dsc_line_S dsc_line; fd_resource = mch_fopen((char *)resource->filename, READBIN); if (fd_resource == NULL) @@ -4216,11 +4683,11 @@ prt_open_resource(resource) EMSG2(_("E624: Can't open file \"%s\""), resource->filename); return FALSE; } - vim_memset(buffer, NUL, sizeof(buffer)); + vim_memset(prt_resfile.buffer, NUL, PRT_FILE_BUFFER_LEN); /* Parse first line to ensure valid resource file */ - (void)fread((char *)buffer, sizeof(char_u), sizeof(buffer), - fd_resource); + prt_resfile.len = fread((char *)prt_resfile.buffer, sizeof(char_u), + PRT_FILE_BUFFER_LEN, fd_resource); if (ferror(fd_resource)) { EMSG2(_("E457: Can't read PostScript resource file \"%s\""), @@ -4229,7 +4696,15 @@ prt_open_resource(resource) return FALSE; } - if (STRNCMP(ch, PRT_RESOURCE_HEADER, STRLEN(PRT_RESOURCE_HEADER)) != 0) + prt_resfile.line_end = -1; + prt_resfile.line_start = 0; + if (!prt_resfile_next_line()) + return FALSE; + + offset = 0; + + if (prt_resfile_strncmp(offset, PRT_RESOURCE_HEADER, + STRLEN(PRT_RESOURCE_HEADER)) != 0) { EMSG2(_("E618: file \"%s\" is not a PostScript resource file"), resource->filename); @@ -4238,32 +4713,34 @@ prt_open_resource(resource) } /* Skip over any version numbers and following ws */ - ch += STRLEN(PRT_RESOURCE_HEADER); - while (!isspace(*ch)) - ch++; - while (isspace(*ch)) - ch++; - - if (STRNCMP(ch, PRT_RESOURCE_RESOURCE, STRLEN(PRT_RESOURCE_RESOURCE)) != 0) + offset += STRLEN(PRT_RESOURCE_HEADER); + offset = prt_resfile_skip_nonws(offset); + if (offset == -1) + return FALSE; + offset = prt_resfile_skip_ws(offset); + if (offset == -1) + return FALSE; + + if (prt_resfile_strncmp(offset, PRT_RESOURCE_RESOURCE, + STRLEN(PRT_RESOURCE_RESOURCE)) != 0) { EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"), resource->filename); fclose(fd_resource); return FALSE; } - ch += STRLEN(PRT_RESOURCE_RESOURCE); + offset += STRLEN(PRT_RESOURCE_RESOURCE); /* Decide type of resource in the file */ - if (STRNCMP(ch, PRT_RESOURCE_PROCSET, STRLEN(PRT_RESOURCE_PROCSET)) == 0) - { + if (prt_resfile_strncmp(offset, PRT_RESOURCE_PROCSET, + STRLEN(PRT_RESOURCE_PROCSET)) == 0) resource->type = PRT_RESOURCE_TYPE_PROCSET; - ch += STRLEN(PRT_RESOURCE_PROCSET); - } - else if (STRNCMP(ch, PRT_RESOURCE_ENCODING, STRLEN(PRT_RESOURCE_ENCODING)) == 0) - { + else if (prt_resfile_strncmp(offset, PRT_RESOURCE_ENCODING, + STRLEN(PRT_RESOURCE_ENCODING)) == 0) resource->type = PRT_RESOURCE_TYPE_ENCODING; - ch += STRLEN(PRT_RESOURCE_ENCODING); - } + else if (prt_resfile_strncmp(offset, PRT_RESOURCE_CMAP, + STRLEN(PRT_RESOURCE_CMAP)) == 0) + resource->type = PRT_RESOURCE_TYPE_CMAP; else { EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"), @@ -4272,53 +4749,50 @@ prt_open_resource(resource) return FALSE; } - /* Consume up to and including the CR/LF/CR_LF */ - while (*ch != PSCR && *ch != PSLF) - ch++; - while (*ch == PSCR || *ch == PSLF) - ch++; - - /* Match %%Title: */ - if (STRNCMP(ch, PRT_RESOURCE_TITLE, STRLEN(PRT_RESOURCE_TITLE)) != 0) + /* Look for title and version of resource */ + resource->title[0] = '\0'; + resource->version[0] = '\0'; + seen_title = FALSE; + seen_version = FALSE; + seen_all = FALSE; + while (!seen_all && prt_next_dsc(&dsc_line)) + { + switch (dsc_line.type) + { + case PRT_DSC_TITLE_TYPE: + STRNCPY(resource->title, dsc_line.string, dsc_line.len); + resource->title[dsc_line.len] = '\0'; + seen_title = TRUE; + if (seen_version) + seen_all = TRUE; + break; + + case PRT_DSC_VERSION_TYPE: + STRNCPY(resource->version, dsc_line.string, dsc_line.len); + resource->version[dsc_line.len] = '\0'; + seen_version = TRUE; + if (seen_title) + seen_all = TRUE; + break; + + case PRT_DSC_ENDCOMMENTS_TYPE: + /* Wont find title or resource after this comment, stop searching */ + seen_all = TRUE; + break; + + case PRT_DSC_MISC_TYPE: + /* Not interested in whatever comment this line had */ + break; + } + } + + if (!seen_title || !seen_version) { EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"), resource->filename); fclose(fd_resource); return FALSE; } - ch += STRLEN(PRT_RESOURCE_TITLE); - - /* Skip ws after %%Title: */ - while (isspace(*ch)) - ch++; - - /* Copy up to the CR/LF/CR_LF */ - ch2 = resource->title; - while (*ch != PSCR && *ch != PSLF) - *ch2++ = *ch++; - *ch2 = '\0'; - while (*ch == PSCR || *ch == PSLF) - ch++; - - /* Match %%Version: */ - if (STRNCMP(ch, PRT_RESOURCE_VERSION, STRLEN(PRT_RESOURCE_VERSION)) != 0) - { - EMSG2(_("E619: file \"%s\" is not a supported PostScript resource file"), - resource->filename); - fclose(fd_resource); - return FALSE; - } - ch += STRLEN(PRT_RESOURCE_VERSION); - - /* Skip ws after %%Version: */ - while (isspace(*ch)) - ch++; - - /* Copy up to the CR/LF/CR_LF */ - ch2 = resource->version; - while (*ch != PSCR && *ch != PSLF) - *ch2++ = *ch++; - *ch2 = '\0'; fclose(fd_resource); @@ -4398,27 +4872,33 @@ prt_dsc_ints(comment, count, ints) } static void -prt_dsc_resources(comment, type, count, strings) +prt_dsc_resources(comment, type, string) char *comment; /* if NULL add to previous */ char *type; - int count; - char **strings; -{ - int i; - + char *string; +{ if (comment != NULL) sprintf((char *)prt_line_buffer, "%%%%%s: %s", comment, type); else sprintf((char *)prt_line_buffer, "%%%%+ %s", type); prt_write_file(prt_line_buffer); - for (i = 0; i < count; i++) - { - sprintf((char *)prt_line_buffer, " %s", strings[i]); - prt_write_file(prt_line_buffer); - } - - prt_write_string("\n"); + sprintf((char *)prt_line_buffer, " %s\n", string); + prt_write_file(prt_line_buffer); +} + + static void +prt_dsc_font_resource(resource, ps_font) + char *resource; + struct prt_ps_font_S *ps_font; +{ + int i; + + prt_dsc_resources(resource, "font", + ps_font->ps_fontname[PRT_PS_FONT_ROMAN]); + for (i = PRT_PS_FONT_BOLD ; i <= PRT_PS_FONT_BOLDOBLIQUE ; i++) + if (ps_font->ps_fontname[i] != NULL) + prt_dsc_resources(NULL, "font", ps_font->ps_fontname[i]); } static void @@ -4489,6 +4969,22 @@ prt_dsc_docmedia(paper_name, width, heig mch_print_cleanup() { #ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + int i; + + /* Free off all CID font names created, but first clear duplicate + * pointers to the same string (when the same font is used for more than + * one style). + */ + for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) + { + if (prt_ps_mb_font.ps_fontname[i] != NULL) + vim_free(prt_ps_mb_font.ps_fontname[i]); + prt_ps_mb_font.ps_fontname[i] = NULL; + } + } + if (prt_do_conv) { convert_setup(&prt_conv, NULL, NULL); @@ -4570,7 +5066,7 @@ prt_font_metrics(font_scale) int font_scale; { prt_line_height = (float)font_scale; - prt_char_width = (float)PRT_PS_FONT_TO_USER(font_scale, prt_ps_font.wx); + prt_char_width = (float)PRT_PS_FONT_TO_USER(font_scale, prt_ps_font->wx); } @@ -4580,6 +5076,13 @@ prt_get_cpl() if (prt_use_number()) { prt_number_width = PRINT_NUMBER_WIDTH * prt_char_width; +#ifdef FEAT_MBYTE + /* If we are outputting multi-byte characters then line numbers will be + * printed with half width characters + */ + if (prt_out_mbyte) + prt_number_width /= 2; +#endif prt_left_margin += prt_number_width; } else @@ -4588,6 +5091,24 @@ prt_get_cpl() return (int)((prt_right_margin - prt_left_margin) / prt_char_width); } + static int +prt_build_cid_fontname(font, name, name_len) + int font; + char *name; + int name_len; +{ + char *fontname; + + fontname = alloc(name_len + 1); + if (fontname == NULL) + return FALSE; + STRNCPY(fontname, name, name_len); + fontname[name_len] = '\0'; + prt_ps_mb_font.ps_fontname[font] = fontname; + + return TRUE; +} + /* * Get number of lines of text that fit on a page (excluding the header). */ @@ -4602,12 +5123,12 @@ prt_get_lpp() * case where the font height can exceed the line height. */ prt_bgcol_offset = (float)PRT_PS_FONT_TO_USER(prt_line_height, - prt_ps_font.bbox_min_y); - if ((prt_ps_font.bbox_max_y - prt_ps_font.bbox_min_y) < 1000.0) + prt_ps_font->bbox_min_y); + if ((prt_ps_font->bbox_max_y - prt_ps_font->bbox_min_y) < 1000.0) { prt_bgcol_offset -= (float)PRT_PS_FONT_TO_USER(prt_line_height, - (1000.0 - (prt_ps_font.bbox_max_y - - prt_ps_font.bbox_min_y)) / 2); + (1000.0 - (prt_ps_font->bbox_max_y - + prt_ps_font->bbox_min_y)) / 2); } /* Get height for topmost line based on background rect offset. */ @@ -4622,6 +5143,61 @@ prt_get_lpp() return lpp - prt_header_height(); } +#ifdef FEAT_MBYTE + static int +prt_match_encoding(p_encoding, p_cmap, pp_mbenc) + char *p_encoding; + struct prt_ps_mbfont_S *p_cmap; + struct prt_ps_encoding_S **pp_mbenc; +{ + int mbenc; + int enc_len; + struct prt_ps_encoding_S *p_mbenc; + + *pp_mbenc = NULL; + /* Look for recognised encoding */ + enc_len = STRLEN(p_encoding); + p_mbenc = p_cmap->encodings; + for (mbenc = 0; mbenc < p_cmap->num_encodings; mbenc++) + { + if (STRNICMP(p_mbenc->encoding, p_encoding, enc_len) == 0) + { + *pp_mbenc = p_mbenc; + return TRUE; + } + p_mbenc++; + } + return FALSE; +} + + static int +prt_match_charset(p_charset, p_cmap, pp_mbchar) + char *p_charset; + struct prt_ps_mbfont_S *p_cmap; + struct prt_ps_charset_S **pp_mbchar; +{ + int mbchar; + int char_len; + struct prt_ps_charset_S *p_mbchar; + + /* Look for recognised character set, using default if one is not given */ + if (*p_charset == NUL) + p_charset = p_cmap->defcs; + char_len = STRLEN(p_charset); + p_mbchar = p_cmap->charsets; + for (mbchar = 0; mbchar < p_cmap->num_charsets; mbchar++) + { + if (STRNICMP(p_mbchar->charset, p_charset, char_len) == 0) + { + *pp_mbchar = p_mbchar; + return TRUE; + } + p_mbchar++; + } + return FALSE; +} +#endif + /*ARGSUSED*/ int mch_print_init(psettings, jobname, forceit) @@ -4638,6 +5214,14 @@ mch_print_init(psettings, jobname, force double right; double top; double bottom; +#ifdef FEAT_MBYTE + int cmap; + int pmcs_len; + char_u *p_encoding; + struct prt_ps_encoding_S *p_mbenc; + struct prt_ps_encoding_S *p_mbenc_first; + struct prt_ps_charset_S *p_mbchar; +#endif #if 0 /* @@ -4658,6 +5242,131 @@ mch_print_init(psettings, jobname, force #endif /* + * Set up font and encoding. + */ +#ifdef FEAT_MBYTE + p_encoding = enc_skip(p_penc); + if (*p_encoding == NUL) + p_encoding = enc_skip(p_enc); + + /* Look for recognised multi-byte coding, and if the charset is recognised. + * This is to cope with the fact that various unicode encodings are + * supported in more than one of CJK. */ + p_mbenc = NULL; + p_mbenc_first = NULL; + p_mbchar = NULL; + for (cmap = 0; cmap < NUM_ELEMENTS(prt_ps_mbfonts); cmap++) + if (prt_match_encoding(p_encoding, &prt_ps_mbfonts[cmap], &p_mbenc)) + { + if (p_mbenc_first == NULL) + p_mbenc_first = p_mbenc; + if (prt_match_charset(p_pmcs, &prt_ps_mbfonts[cmap], &p_mbchar)) + break; + } + + /* Use first encoding matched if no charset matched */ + if (p_mbchar == NULL && p_mbenc_first != NULL) + p_mbenc = p_mbenc_first; + + prt_out_mbyte = (p_mbenc != NULL); + if (prt_out_mbyte) + { + /* Build CMap name - will be same for all multi-byte fonts used */ + prt_cmap[0] = '\0'; + + prt_custom_cmap = prt_out_mbyte && p_mbchar == NULL; + + if (!prt_custom_cmap) + { + /* Check encoding and character set are compatible */ + if ((p_mbenc->needs_charset&p_mbchar->has_charset) == 0) + { + EMSG(_("E673: Incompatible multi-byte encoding and character set.")); + return FALSE; + } + + /* Add charset name if not empty */ + if (p_mbchar->cmap_charset != NULL) + { + STRCAT(prt_cmap, p_mbchar->cmap_charset); + STRCAT(prt_cmap, "-"); + } + } + else + { + /* Add custom CMap character set name */ + pmcs_len = STRLEN(p_pmcs); + if (pmcs_len == 0) + { + EMSG(_("E674: printmbcharset cannot be empty with multi-byte encoding.")); + return FALSE; + } + STRNCPY(prt_cmap, p_pmcs, STRLEN(p_pmcs)); + prt_cmap[pmcs_len] = '\0'; + STRCAT(prt_cmap, "-"); + } + + /* CMap name ends with (optional) encoding name and -H for horizontal */ + if (p_mbenc->cmap_encoding != NULL) + { + STRCAT(prt_cmap, p_mbenc->cmap_encoding); + STRCAT(prt_cmap, "-"); + } + STRCAT(prt_cmap, "H"); + + if (!mbfont_opts[OPT_MBFONT_REGULAR].present) + { + EMSG(_("E675: No default font specfifed for multi-byte printing.")); + return FALSE; + } + + /* Derive CID font names with fallbacks if not defined */ + if (!prt_build_cid_fontname(PRT_PS_FONT_ROMAN, + mbfont_opts[OPT_MBFONT_REGULAR].string, + mbfont_opts[OPT_MBFONT_REGULAR].strlen)) + return FALSE; + if (mbfont_opts[OPT_MBFONT_BOLD].present) + if (!prt_build_cid_fontname(PRT_PS_FONT_BOLD, + mbfont_opts[OPT_MBFONT_BOLD].string, + mbfont_opts[OPT_MBFONT_BOLD].strlen)) + return FALSE; + if (mbfont_opts[OPT_MBFONT_OBLIQUE].present) + if (!prt_build_cid_fontname(PRT_PS_FONT_OBLIQUE, + mbfont_opts[OPT_MBFONT_OBLIQUE].string, + mbfont_opts[OPT_MBFONT_OBLIQUE].strlen)) + return FALSE; + if (mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].present) + if (!prt_build_cid_fontname(PRT_PS_FONT_BOLDOBLIQUE, + mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string, + mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen)) + return FALSE; + + /* Check if need to use Courier for ASCII code range, and if so pick up + * the encoding to use */ + prt_use_courier = mbfont_opts[OPT_MBFONT_USECOURIER].present && + (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_USECOURIER].string[0]) == 'y'); + if (prt_use_courier) + { + /* Use national ASCII variant unless ASCII wanted */ + if (mbfont_opts[OPT_MBFONT_ASCII].present && + (TOLOWER_ASC(mbfont_opts[OPT_MBFONT_ASCII].string[0]) == 'y')) + prt_ascii_encoding = "ascii"; + else + prt_ascii_encoding = prt_ps_mbfonts[cmap].ascii_enc; + } + + prt_ps_font = &prt_ps_mb_font; + } + else +#endif + { +#ifdef FEAT_MBYTE + prt_use_courier = FALSE; +#endif + prt_ps_font = &prt_ps_courier_font; + } + + /* * Find the size of the paper and set the margins. */ prt_portrait = (!printer_opts[OPT_PRINT_PORTRAIT].present @@ -4805,7 +5514,12 @@ mch_print_init(psettings, jobname, force return FAIL; } - ga_init2(&prt_ps_buffer, (int)sizeof(char), PRT_PS_DEFAULT_BUFFER_SIZE); + prt_bufsiz = psettings->chars_per_line; +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + prt_bufsiz *= 2; +#endif + ga_init2(&prt_ps_buffer, (int)sizeof(char), prt_bufsiz); prt_page_num = 0; @@ -4827,7 +5541,6 @@ prt_add_resource(resource) { FILE* fd_resource; char_u resource_buffer[512]; - char *resource_name[1]; size_t bytes_read; fd_resource = mch_fopen((char *)resource->filename, READBIN); @@ -4836,9 +5549,8 @@ prt_add_resource(resource) EMSG2(_("E456: Can't open file \"%s\""), resource->filename); return FALSE; } - resource_name[0] = (char *)resource->title; prt_dsc_resources("BeginResource", - resource_types[resource->type], 1, resource_name); + prt_resource_types[resource->type], resource->title); prt_dsc_textline("BeginDocument", (char *)resource->filename); @@ -4878,7 +5590,6 @@ mch_print_begin(psettings) time_t now; int bbox[4]; char *p_time; - char *resource[1]; double left; double right; double top; @@ -4888,7 +5599,8 @@ mch_print_begin(psettings) char_u buffer[256]; char_u *p_encoding; #ifdef FEAT_MBYTE - int props; + struct prt_ps_resource_S res_cidfont; + struct prt_ps_resource_S res_cmap; #endif /* @@ -4896,8 +5608,9 @@ mch_print_begin(psettings) */ prt_dsc_start(); prt_dsc_textline("Title", (char *)psettings->jobname); - /* TODO - platform dependent user name retrieval */ - prt_dsc_textline("For", "Unknown"); + if (!get_user_name(buffer, 256)) + STRCPY(buffer, "Unknown"); + prt_dsc_textline("For", buffer); prt_dsc_textline("Creator", VIM_VERSION_LONG); /* Note: to ensure Clean8bit I don't think we can use LC_TIME */ now = time(NULL); @@ -4946,10 +5659,22 @@ mch_print_begin(psettings) prt_mediasize[prt_media].width, prt_mediasize[prt_media].height, (double)0, NULL, NULL); - prt_dsc_resources("DocumentNeededResources", "font", 4, - prt_ps_font.ps_fontname); - - /* Search for external resources we supply */ + /* Define fonts needed */ +#ifdef FEAT_MBYTE + if (!prt_out_mbyte || prt_use_courier) +#endif + prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + prt_dsc_font_resource((prt_use_courier ? NULL + : "DocumentNeededResources"), &prt_ps_mb_font); + if (!prt_custom_cmap) + prt_dsc_resources(NULL, "cmap", prt_cmap); + } +#endif + + /* Search for external resources VIM supplies */ if (!prt_find_resource("prolog", &res_prolog)) { EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\"")); @@ -4959,66 +5684,139 @@ mch_print_begin(psettings) return FALSE; if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION)) return FALSE; +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + /* Look for required version of multi-byte printing procset */ + if (!prt_find_resource("cidfont", &res_cidfont)) + { + EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\"")); + return FALSE; + } + if (!prt_open_resource(&res_cidfont)) + return FALSE; + if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION)) + return FALSE; + } +#endif + /* Find an encoding to use for printing. * Check 'printencoding'. If not set or not found, then use 'encoding'. If * that cannot be found then default to "latin1". * Note: VIM specific encoding header is always skipped. */ #ifdef FEAT_MBYTE - props = enc_canon_props(p_enc); -#endif - p_encoding = enc_skip(p_penc); - if (*p_encoding == NUL - || !prt_find_resource((char *)p_encoding, &res_encoding)) - { - /* 'printencoding' not set or not supported - find alternate */ + if (!prt_out_mbyte) + { +#endif + p_encoding = enc_skip(p_penc); + if (*p_encoding == NUL + || !prt_find_resource((char *)p_encoding, &res_encoding)) + { + /* 'printencoding' not set or not supported - find alternate */ #ifdef FEAT_MBYTE - p_encoding = enc_skip(p_enc); - if (!(props & ENC_8BIT) - || !prt_find_resource((char *)p_encoding, &res_encoding)) - { - /* 8-bit 'encoding' is not supported */ -#endif - /* Use latin1 as default printing encoding */ - p_encoding = (char_u *)"latin1"; - if (!prt_find_resource((char *)p_encoding, &res_encoding)) - { - EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), - p_encoding); - return FALSE; - } + int props; + + p_encoding = enc_skip(p_enc); + props = enc_canon_props(p_encoding); + if (!(props & ENC_8BIT) + || !prt_find_resource((char *)p_encoding, &res_encoding)) + /* 8-bit 'encoding' is not supported */ +#endif + { + /* Use latin1 as default printing encoding */ + p_encoding = (char_u *)"latin1"; + if (!prt_find_resource((char *)p_encoding, &res_encoding)) + { + EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), + p_encoding); + return FALSE; + } + } + } + if (!prt_open_resource(&res_encoding)) + return FALSE; + /* For the moment there are no checks on encoding resource files to + * perform */ #ifdef FEAT_MBYTE - } -#endif - } - if (!prt_open_resource(&res_encoding)) - return FALSE; - /* For the moment there are no checks on encoding resource files to perform */ -#ifdef FEAT_MBYTE - /* Set up encoding conversion if starting from multi-byte */ - props = enc_canon_props(p_enc); - if (!(props & ENC_8BIT)) - { + } + else + { + p_encoding = enc_skip(p_penc); + if (*p_encoding == NUL) + p_encoding = enc_skip(p_enc); + if (prt_use_courier) + { + /* Include ASCII range encoding vector */ + if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) + { + EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), + prt_ascii_encoding); + return FALSE; + } + if (!prt_open_resource(&res_encoding)) + return FALSE; + /* For the moment there are no checks on encoding resource files to + * perform */ + } + } + + prt_conv.vc_type = CONV_NONE; + if (!(enc_canon_props(p_enc) & enc_canon_props(p_encoding) & ENC_8BIT)) { + /* Set up encoding conversion if required */ if (FAIL == convert_setup(&prt_conv, p_enc, p_encoding)) { - EMSG2(_("E620: Unable to convert from multi-byte to \"%s\" encoding"), + EMSG2(_("E620: Unable to convert to print encoding \"%s\""), p_encoding); return FALSE; } prt_do_conv = TRUE; } + prt_do_conv = prt_conv.vc_type != CONV_NONE; + + if (prt_out_mbyte && prt_custom_cmap) + { + /* Find user supplied CMap */ + if (!prt_find_resource(prt_cmap, &res_cmap)) + { + EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), + prt_cmap); + return FALSE; + } + if (!prt_open_resource(&res_cmap)) + return FALSE; + } #endif /* List resources supplied */ - resource[0] = (char *)buffer; STRCPY(buffer, res_prolog.title); STRCAT(buffer, " "); STRCAT(buffer, res_prolog.version); - prt_dsc_resources("DocumentSuppliedResources", "procset", 1, resource); - STRCPY(buffer, res_encoding.title); - STRCAT(buffer, " "); - STRCAT(buffer, res_encoding.version); - prt_dsc_resources(NULL, "encoding", 1, resource); + prt_dsc_resources("DocumentSuppliedResources", "procset", buffer); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + STRCPY(buffer, res_cidfont.title); + STRCAT(buffer, " "); + STRCAT(buffer, res_cidfont.version); + prt_dsc_resources(NULL, "procset", buffer); + + if (prt_custom_cmap) + { + STRCPY(buffer, res_cmap.title); + STRCAT(buffer, " "); + STRCAT(buffer, res_cmap.version); + prt_dsc_resources(NULL, "cmap", buffer); + } + } + if (!prt_out_mbyte || prt_use_courier) +#endif + { + STRCPY(buffer, res_encoding.title); + STRCAT(buffer, " "); + STRCAT(buffer, res_encoding.version); + prt_dsc_resources(NULL, "encoding", buffer); + } prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate, #ifdef FEAT_SYN_HL psettings->do_syntax @@ -5034,7 +5832,20 @@ mch_print_begin(psettings) prt_dsc_noarg("BeginDefaults"); /* List font resources most likely common to all pages */ - prt_dsc_resources("PageResources", "font", 4, prt_ps_font.ps_fontname); +#ifdef FEAT_MBYTE + if (!prt_out_mbyte || prt_use_courier) +#endif + prt_dsc_font_resource("PageResources", &prt_ps_courier_font); +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + prt_dsc_font_resource((prt_use_courier ? NULL : "PageResources"), + &prt_ps_mb_font); + if (!prt_custom_cmap) + prt_dsc_resources(NULL, "cmap", prt_cmap); + } +#endif + /* Paper will be used for all pages */ prt_dsc_textline("PageMedia", prt_mediasize[prt_media].name); @@ -5045,13 +5856,27 @@ mch_print_begin(psettings) */ prt_dsc_noarg("BeginProlog"); - /* For now there is just the one procset to be included in the PS file. */ + /* Add required procsets - NOTE: order is important! */ if (!prt_add_resource(&res_prolog)) return FALSE; - - /* There will be only one font encoding to be included in the PS file. */ - if (!prt_add_resource(&res_encoding)) - return FALSE; +#ifdef FEAT_MBYTE + if (prt_out_mbyte) + { + /* Add CID font procset, and any user supplied CMap */ + if (!prt_add_resource(&res_cidfont)) + return FALSE; + if (prt_custom_cmap && !prt_add_resource(&res_cmap)) + return FALSE; + } +#endif + +#ifdef FEAT_MBYTE + if (!prt_out_mbyte || prt_use_courier) +#endif + /* There will be only one Roman font encoding to be included in the PS + * file. */ + if (!prt_add_resource(&res_encoding)) + return FALSE; prt_dsc_noarg("EndProlog"); @@ -5074,28 +5899,93 @@ mch_print_begin(psettings) prt_write_string("c\n"); /* Font resource inclusion and definition */ - prt_dsc_resources("IncludeResource", "font", 1, - &prt_ps_font.ps_fontname[PRT_PS_FONT_ROMAN]); - prt_def_font("F0", (char *)p_encoding, (int)prt_line_height, - prt_ps_font.ps_fontname[PRT_PS_FONT_ROMAN]); - prt_dsc_resources("IncludeResource", "font", 1, - &prt_ps_font.ps_fontname[PRT_PS_FONT_BOLD]); - prt_def_font("F1", (char *)p_encoding, (int)prt_line_height, - prt_ps_font.ps_fontname[PRT_PS_FONT_BOLD]); - prt_dsc_resources("IncludeResource", "font", 1, - &prt_ps_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); - prt_def_font("F2", (char *)p_encoding, (int)prt_line_height, - prt_ps_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); - prt_dsc_resources("IncludeResource", "font", 1, - &prt_ps_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); - prt_def_font("F3", (char *)p_encoding, (int)prt_line_height, - prt_ps_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); +#ifdef FEAT_MBYTE + if (!prt_out_mbyte || prt_use_courier) + { + /* When using Courier for ASCII range when printing multi-byte, need to + * pick up ASCII encoding to use with it. */ + if (prt_use_courier) + p_encoding = prt_ascii_encoding; +#endif + prt_dsc_resources("IncludeResource", "font", + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]); + prt_def_font("F0", (char *)p_encoding, (int)prt_line_height, + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]); + prt_dsc_resources("IncludeResource", "font", + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]); + prt_def_font("F1", (char *)p_encoding, (int)prt_line_height, + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLD]); + prt_dsc_resources("IncludeResource", "font", + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); + prt_def_font("F2", (char *)p_encoding, (int)prt_line_height, + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); + prt_dsc_resources("IncludeResource", "font", + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); + prt_def_font("F3", (char *)p_encoding, (int)prt_line_height, + prt_ps_courier_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); +#ifdef FEAT_MBYTE + } + if (prt_out_mbyte) + { + /* Define the CID fonts to be used in the job. Typically CJKV fonts do + * not have an italic form being a western style, so where no font is + * defined for these faces VIM falls back to an existing face. + * Note: if using Courier for the ASCII range then the printout will + * have bold/italic/bolditalic regardless of the setting of printmbfont. + */ + prt_dsc_resources("IncludeResource", "font", + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]); + if (!prt_custom_cmap) + prt_dsc_resources("IncludeResource", "cmap", prt_cmap); + prt_def_cidfont("CF0", (int)prt_line_height, + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_ROMAN]); + + if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD] != NULL) + { + prt_dsc_resources("IncludeResource", "font", + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]); + if (!prt_custom_cmap) + prt_dsc_resources("IncludeResource", "cmap", prt_cmap); + prt_def_cidfont("CF1", (int)prt_line_height, + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLD]); + } + else + /* Use ROMAN for BOLD */ + prt_dup_cidfont("CF0", "CF1"); + + if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE] != NULL) + { + prt_dsc_resources("IncludeResource", "font", + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); + if (!prt_custom_cmap) + prt_dsc_resources("IncludeResource", "cmap", prt_cmap); + prt_def_cidfont("CF2", (int)prt_line_height, + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_OBLIQUE]); + } + else + /* Use ROMAN for OBLIQUE */ + prt_dup_cidfont("CF0", "CF2"); + + if (prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE] != NULL) + { + prt_dsc_resources("IncludeResource", "font", + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); + if (!prt_custom_cmap) + prt_dsc_resources("IncludeResource", "cmap", prt_cmap); + prt_def_cidfont("CF3", (int)prt_line_height, + prt_ps_mb_font.ps_fontname[PRT_PS_FONT_BOLDOBLIQUE]); + } + else + /* Use BOLD for BOLDOBLIQUE */ + prt_dup_cidfont("CF1", "CF3"); + } +#endif /* Misc constant vars used for underlining and background rects */ prt_def_var("UO", PRT_PS_FONT_TO_USER(prt_line_height, - prt_ps_font.uline_offset), 2); + prt_ps_font->uline_offset), 2); prt_def_var("UW", PRT_PS_FONT_TO_USER(prt_line_height, - prt_ps_font.uline_width), 2); + prt_ps_font->uline_width), 2); prt_def_var("BO", prt_bgcol_offset, 2); prt_dsc_noarg("EndSetup"); @@ -5168,7 +6058,14 @@ mch_print_begin_page(str) prt_dsc_noarg("BeginPageSetup"); - prt_write_string("sv\n0 g\nF0 sf\n"); + prt_write_string("sv\n0 g\n"); +#ifdef FEAT_MBYTE + prt_in_ascii = !prt_out_mbyte; + if (prt_out_mbyte) + prt_write_string("CF0 sf\n"); + else +#endif + prt_write_string("F0 sf\n"); prt_fgcol = PRCOLOR_BLACK; prt_bgcol = PRCOLOR_WHITE; prt_font = PRT_PS_FONT_ROMAN; @@ -5213,6 +6110,9 @@ mch_print_start_line(margin, page_line) prt_attribute_change = TRUE; prt_need_moveto = TRUE; +#ifdef FEAT_MBYTE + prt_half_width = FALSE; +#endif } /*ARGSUSED*/ @@ -5224,6 +6124,68 @@ mch_print_text_out(p, len) int need_break; char_u ch; char_u ch_buff[8]; + float char_width; + float next_pos; +#ifdef FEAT_MBYTE + int in_ascii; + int half_width; +#endif + + char_width = prt_char_width; + +#ifdef FEAT_MBYTE + /* Ideally VIM would create a rearranged CID font to combine a Roman and + * CJKV font to do what VIM is doing here - use a Roman font for characters + * in the ASCII range, and the origingal CID font for everything else. + * The problem is that GhostScript still (as of 8.13) does not support + * rearranged fonts even though they have been documented by Adobe for 7 + * years! If they ever do, a lot of this code will disappear. + */ + if (prt_use_courier) + { + in_ascii = (len == 1 && *p < 0x80); + if (prt_in_ascii) + { + if (!in_ascii) + { + /* No longer in ASCII range - need to switch font */ + prt_in_ascii = FALSE; + prt_need_font = TRUE; + prt_attribute_change = TRUE; + } + } + else if (in_ascii) + { + /* Now in ASCII range - need to switch font */ + prt_in_ascii = TRUE; + prt_need_font = TRUE; + prt_attribute_change = TRUE; + } + } + if (prt_out_mbyte) + { + half_width = ((*mb_ptr2cells)(p) == 1); + if (half_width) + char_width /= 2; + if (prt_half_width) + { + if (!half_width) + { + prt_half_width = FALSE; + prt_pos_x += prt_char_width/4; + prt_need_moveto = TRUE; + prt_attribute_change = TRUE; + } + } + else if (half_width) + { + prt_half_width = TRUE; + prt_pos_x += prt_char_width/4; + prt_need_moveto = TRUE; + prt_attribute_change = TRUE; + } + } +#endif /* Output any required changes to the graphics state, after flushing any * text buffered so far. @@ -5232,7 +6194,7 @@ mch_print_text_out(p, len) { prt_flush_buffer(); /* Reset count of number of chars that will be printed */ - prt_text_count = 0; + prt_text_run = 0; if (prt_need_moveto) { @@ -5244,10 +6206,15 @@ mch_print_text_out(p, len) } if (prt_need_font) { - prt_write_string("F"); - prt_write_int(prt_font); - prt_write_string("sf\n"); - prt_need_font = FALSE; +#ifdef FEAT_MBYTE + if (!prt_in_ascii) + prt_write_string("CF"); + else +#endif + prt_write_string("F"); + prt_write_int(prt_font); + prt_write_string("sf\n"); + prt_need_font = FALSE; } if (prt_need_fgcol) { @@ -5258,9 +6225,7 @@ mch_print_text_out(p, len) prt_write_real(r / 255.0, 3); if (r == g && g == b) - { prt_write_string("g\n"); - } else { prt_write_real(g / 255.0, 3); @@ -5295,46 +6260,64 @@ mch_print_text_out(p, len) if (p == NULL) p = (char_u *)""; } -#endif - /* Add next character to buffer of characters to output. - * Note: One printed character may require several PS characters to - * represent it, but we only count them as one printed character. - */ - ch = *p; - if (ch < 32 || ch == '(' || ch == ')' || ch == '\\') - { - /* Convert non-printing characters to either their escape or octal - * sequence, ensures PS sent over a serial line does not interfere with - * the comms protocol. - * Note: For EBCDIC we need to write out the escape sequences as ASCII - * codes! - * Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK! - */ - ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); - switch (ch) - { - case BS: ga_append(&prt_ps_buffer, IF_EB('b', 0142)); break; - case TAB: ga_append(&prt_ps_buffer, IF_EB('t', 0164)); break; - case NL: ga_append(&prt_ps_buffer, IF_EB('n', 0156)); break; - case FF: ga_append(&prt_ps_buffer, IF_EB('f', 0146)); break; - case CAR: ga_append(&prt_ps_buffer, IF_EB('r', 0162)); break; - case '(': ga_append(&prt_ps_buffer, IF_EB('(', 0050)); break; - case ')': ga_append(&prt_ps_buffer, IF_EB(')', 0051)); break; - case '\\': ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); break; - - default: - sprintf((char *)ch_buff, "%03o", (unsigned int)ch); -#ifdef EBCDIC - ebcdic2ascii(ch_buff, 3); -#endif - ga_append(&prt_ps_buffer, ch_buff[0]); - ga_append(&prt_ps_buffer, ch_buff[1]); - ga_append(&prt_ps_buffer, ch_buff[2]); - break; - } + + if (prt_out_mbyte) + { + /* Multi-byte character strings are represented more efficiently as hex + * strings when outputting clean 8 bit PS. + */ + do + { + ch = prt_hexchar[(*p) >> 4]; + ga_append(&prt_ps_buffer, ch); + ch = prt_hexchar[(*p) & 0xf]; + ga_append(&prt_ps_buffer, ch); + p++; + } + while (--len); } else - ga_append(&prt_ps_buffer, ch); +#endif + { + /* Add next character to buffer of characters to output. + * Note: One printed character may require several PS characters to + * represent it, but we only count them as one printed character. + */ + ch = *p; + if (ch < 32 || ch == '(' || ch == ')' || ch == '\\') + { + /* Convert non-printing characters to either their escape or octal + * sequence, ensures PS sent over a serial line does not interfere + * with the comms protocol. Note: For EBCDIC we need to write out + * the escape sequences as ASCII codes! + * Note 2: Char codes < 32 are identical in EBCDIC and ASCII AFAIK! + */ + ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); + switch (ch) + { + case BS: ga_append(&prt_ps_buffer, IF_EB('b', 0142)); break; + case TAB: ga_append(&prt_ps_buffer, IF_EB('t', 0164)); break; + case NL: ga_append(&prt_ps_buffer, IF_EB('n', 0156)); break; + case FF: ga_append(&prt_ps_buffer, IF_EB('f', 0146)); break; + case CAR: ga_append(&prt_ps_buffer, IF_EB('r', 0162)); break; + case '(': ga_append(&prt_ps_buffer, IF_EB('(', 0050)); break; + case ')': ga_append(&prt_ps_buffer, IF_EB(')', 0051)); break; + case '\\': ga_append(&prt_ps_buffer, IF_EB('\\', 0134)); break; + + default: + sprintf((char *)ch_buff, "%03o", (unsigned int)ch); +#ifdef EBCDIC + ebcdic2ascii(ch_buff, 3); +#endif + ga_append(&prt_ps_buffer, ch_buff[0]); + ga_append(&prt_ps_buffer, ch_buff[1]); + ga_append(&prt_ps_buffer, ch_buff[2]); + break; + } + } + else + ga_append(&prt_ps_buffer, ch); + } #ifdef FEAT_MBYTE /* Need to free any translated characters */ @@ -5342,11 +6325,13 @@ mch_print_text_out(p, len) vim_free(p); #endif - prt_text_count++; - prt_pos_x += prt_char_width; - - /* The downside of fp - need a little tolerance in the right margin check */ - need_break = (prt_pos_x + prt_char_width > (prt_right_margin + 0.01)); + prt_text_run += char_width; + prt_pos_x += char_width; + + /* The downside of fp - use relative error on right margin check */ + next_pos = prt_pos_x + prt_char_width; + need_break = (next_pos > prt_right_margin) && + ((next_pos - prt_right_margin) > (prt_right_margin*1e-5)); if (need_break) prt_flush_buffer(); diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -80,6 +80,7 @@ static void correct_cmdspos __ARGS((int static void alloc_cmdbuff __ARGS((int len)); static int realloc_cmdbuff __ARGS((int len)); static void draw_cmdline __ARGS((int start, int len)); +static int cmdline_paste __ARGS((int regname, int literally)); #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK) static void redrawcmd_preedit __ARGS((void)); #endif @@ -2536,6 +2537,102 @@ put_on_cmdline(str, len, redraw) return retval; } +/* + * paste a yank register into the command line. + * used by CTRL-R command in command-line mode + * insert_reg() can't be used here, because special characters from the + * register contents will be interpreted as commands. + * + * return FAIL for failure, OK otherwise + */ + static int +cmdline_paste(regname, literally) + int regname; + int literally; /* Insert text literally instead of "as typed" */ +{ + long i; + char_u *arg; + int allocated; + struct cmdline_info save_ccline; + + /* check for valid regname; also accept special characters for CTRL-R in + * the command line */ + if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W + && regname != Ctrl_A && !valid_yank_reg(regname, FALSE)) + return FAIL; + + /* A register containing CTRL-R can cause an endless loop. Allow using + * CTRL-C to break the loop. */ + line_breakcheck(); + if (got_int) + return FAIL; + +#ifdef FEAT_CLIPBOARD + regname = may_get_selection(regname); +#endif + + /* Need to save and restore ccline, because obtaining the "=" register may + * execute "normal :cmd" and overwrite it. */ + save_ccline = ccline; + ccline.cmdbuff = NULL; + ccline.cmdprompt = NULL; + i = get_spec_reg(regname, &arg, &allocated, TRUE); + ccline = save_ccline; + + if (i) + { + /* Got the value of a special register in "arg". */ + if (arg == NULL) + return FAIL; + cmdline_paste_str(arg, literally); + if (allocated) + vim_free(arg); + return OK; + } + + return cmdline_paste_reg(regname, literally); +} + +/* + * Put a string on the command line. + * When "literally" is TRUE, insert literally. + * When "literally" is FALSE, insert as typed, but don't leave the command + * line. + */ + void +cmdline_paste_str(s, literally) + char_u *s; + int literally; +{ + int c, cv; + + if (literally) + put_on_cmdline(s, -1, TRUE); + else + while (*s != NUL) + { + cv = *s; + if (cv == Ctrl_V && s[1]) + ++s; +#ifdef FEAT_MBYTE + if (has_mbyte) + { + c = mb_ptr2char(s); + s += mb_char2len(c); + } + else +#endif + c = *s++; + if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL +#ifdef UNIX + || c == intr_char +#endif + || (c == Ctrl_BSL && *s == Ctrl_N)) + stuffcharReadbuff(Ctrl_V); + stuffcharReadbuff(c); + } +} + #ifdef FEAT_WILDMENU /* * Delete characters on the command line, from "from" to the current diff --git a/src/globals.h b/src/globals.h --- a/src/globals.h +++ b/src/globals.h @@ -1102,6 +1102,30 @@ EXTERN option_table_T printer_opts[OPT_P # define PRT_UNIT_MM 2 # define PRT_UNIT_POINT 3 # define PRT_UNIT_NAMES {"pc", "in", "mm", "pt"} + +# ifdef FEAT_MBYTE +# define OPT_MBFONT_USECOURIER 0 +# define OPT_MBFONT_ASCII 1 +# define OPT_MBFONT_REGULAR 2 +# define OPT_MBFONT_BOLD 3 +# define OPT_MBFONT_OBLIQUE 4 +# define OPT_MBFONT_BOLDOBLIQUE 5 +# define OPT_MBFONT_NUM_OPTIONS 6 +# +EXTERN option_table_T mbfont_opts[OPT_MBFONT_NUM_OPTIONS] +# ifdef DO_INIT + = +{ + {"c", FALSE, 0, NULL, 0, FALSE}, + {"a", FALSE, 0, NULL, 0, FALSE}, + {"r", FALSE, 0, NULL, 0, FALSE}, + {"b", FALSE, 0, NULL, 0, FALSE}, + {"i", FALSE, 0, NULL, 0, FALSE}, + {"o", FALSE, 0, NULL, 0, FALSE}, +} +# endif +; +# endif #endif #ifdef FEAT_XCLIPBOARD diff --git a/src/if_mzsch.c b/src/if_mzsch.c --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -21,17 +21,6 @@ * 3. I don't use K&R-style functions. Anyway, MzScheme headers are ANSI. */ -/* TODO - * way to catch Vim errors (incl. verbose messages) - * libmzscheme.dll dynamic loading - * macros to pass modifiers (e.g. (browse edit)) - * opportunity to use shared mzscheme libraries on Unix - * event on-change-mode - * Scheme-driven coloring - * global exn-handler - * embed Read-Eval-Print-Loop - */ - #include "vim.h" #include "if_mzsch.h" @@ -44,7 +33,6 @@ typedef struct Scheme_Type tag; Scheme_Env *env; buf_T *buf; - Scheme_Object *text_objects; } vim_mz_buffer; #define INVALID_BUFFER_VALUE ((buf_T *)(-1)) @@ -2077,20 +2065,6 @@ win_T *get_valid_window(void *obj) return win; } -#if 0 - int -mzvim_bufferp(Scheme_Object *obj) -{ - return SCHEME_VIMBUFFERP(obj); -} - - int -mzvim_windowp(Scheme_Object *obj) -{ - return SCHEME_VIMWINDOWP(obj); -} -#endif - int mzthreads_allowed(void) { @@ -2215,14 +2189,6 @@ get_vim_curr_window(void) return (vim_mz_window *)curwin->mzscheme_ref; } -#if 0 - char * -mzscheme_version(void) -{ - return scheme_version(); -} -#endif - static void make_modules(Scheme_Env *env) { diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -94,13 +94,10 @@ struct block_def static void shift_block __ARGS((oparg_T *oap, int amount)); static void block_insert __ARGS((oparg_T *oap, char_u *s, int b_insert, struct block_def*bdp)); #endif -static void get_yank_register __ARGS((int regname, int writing)); static int stuff_yank __ARGS((int, char_u *)); static void put_reedit_in_typebuf __ARGS((void)); static int put_in_typebuf __ARGS((char_u *s, int colon)); static void stuffescaped __ARGS((char_u *arg, int literally)); -static int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg)); -static void cmdline_paste_str __ARGS((char_u *s, int literally)); #ifdef FEAT_MBYTE static void mb_adjust_opend __ARGS((oparg_T *oap)); #endif @@ -820,7 +817,7 @@ valid_yank_reg(regname, writing) * If regname is 0 and writing, use register 0 * If regname is 0 and reading, use previous register */ - static void + void get_yank_register(regname, writing) int regname; int writing; @@ -864,14 +861,12 @@ get_yank_register(regname, writing) y_previous = y_current; } -#ifdef FEAT_CLIPBOARD +#if defined(FEAT_CLIPBOARD) || defined(PROTO) /* * When "regname" is a clipboard register, obtain the selection. If it's not * available return zero, otherwise return "regname". */ -static int may_get_selection __ARGS((int regname)); - - static int + int may_get_selection(regname) int regname; { @@ -1347,7 +1342,7 @@ stuffescaped(arg, literally) /* * If "regname" is a special register, return a pointer to its value. */ - static int + int get_spec_reg(regname, argp, allocated, errmsg) int regname; char_u **argp; @@ -1426,47 +1421,20 @@ get_spec_reg(regname, argp, allocated, e } /* - * paste a yank register into the command line. - * used by CTRL-R command in command-line mode + * Paste a yank register into the command line. + * Only for non-special registers. + * Used by CTRL-R command in command-line mode * insert_reg() can't be used here, because special characters from the * register contents will be interpreted as commands. * * return FAIL for failure, OK otherwise */ int -cmdline_paste(regname, literally) +cmdline_paste_reg(regname, literally) int regname; int literally; /* Insert text literally instead of "as typed" */ { long i; - char_u *arg; - int allocated; - - /* check for valid regname; also accept special characters for CTRL-R in - * the command line */ - if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W - && regname != Ctrl_A && !valid_yank_reg(regname, FALSE)) - return FAIL; - - /* A register containing CTRL-R can cause an endless loop. Allow using - * CTRL-C to break the loop. */ - line_breakcheck(); - if (got_int) - return FAIL; - -#ifdef FEAT_CLIPBOARD - regname = may_get_selection(regname); -#endif - - if (get_spec_reg(regname, &arg, &allocated, TRUE)) - { - if (arg == NULL) - return FAIL; - cmdline_paste_str(arg, literally); - if (allocated) - vim_free(arg); - return OK; - } get_yank_register(regname, FALSE); if (y_current->y_array == NULL) @@ -1489,46 +1457,6 @@ cmdline_paste(regname, literally) return OK; } -/* - * Put a string on the command line. - * When "literally" is TRUE, insert literally. - * When "literally" is FALSE, insert as typed, but don't leave the command - * line. - */ - static void -cmdline_paste_str(s, literally) - char_u *s; - int literally; -{ - int c, cv; - - if (literally) - put_on_cmdline(s, -1, TRUE); - else - while (*s != NUL) - { - cv = *s; - if (cv == Ctrl_V && s[1]) - ++s; -#ifdef FEAT_MBYTE - if (has_mbyte) - { - c = mb_ptr2char(s); - s += mb_char2len(c); - } - else -#endif - c = *s++; - if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL -#ifdef UNIX - || c == intr_char -#endif - || (c == Ctrl_BSL && *s == Ctrl_N)) - stuffcharReadbuff(Ctrl_V); - stuffcharReadbuff(c); - } -} - #if defined(FEAT_CLIPBOARD) || defined(PROTO) /* * Adjust the register name pointed to with "rp" for the clipboard being diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -1678,6 +1678,24 @@ static struct vimoption {(char_u *)NULL, (char_u *)0L} #endif }, + {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF, +#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) + (char_u *)&p_pmcs, PV_NONE, + {(char_u *)"", (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} +#endif + }, + {"printmbfont", "pmbfn", P_STRING|P_VI_DEF, +#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE) + (char_u *)&p_pmfn, PV_NONE, + {(char_u *)"", (char_u *)0L} +#else + (char_u *)NULL, PV_NONE, + {(char_u *)NULL, (char_u *)0L} +#endif + }, {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP, #ifdef FEAT_PRINTER (char_u *)&p_popt, PV_NONE, @@ -5283,6 +5301,11 @@ did_set_string_option(opt_idx, varp, new #ifdef FEAT_PRINTER else if (varp == &p_popt) errmsg = parse_list_options(p_popt, printer_opts, OPT_PRINT_NUM_OPTIONS); + +# ifdef FEAT_MBYTE + else if (varp == &p_pmfn) + errmsg = parse_list_options(p_pmfn, mbfont_opts, OPT_MBFONT_NUM_OPTIONS); +# endif #endif #ifdef FEAT_LANGMAP diff --git a/src/option.h b/src/option.h --- a/src/option.h +++ b/src/option.h @@ -451,6 +451,10 @@ EXTERN char_u *p_pdev; /* 'printdevice' # ifdef FEAT_POSTSCRIPT EXTERN char_u *p_penc; /* 'printencoding' */ EXTERN char_u *p_pexpr; /* 'printexpr' */ +# ifdef FEAT_MBYTE +EXTERN char_u *p_pmfn; /* 'printmbfont' */ +EXTERN char_u *p_pmcs; /* 'printmbcharset' */ +# endif # endif EXTERN char_u *p_pfn; /* 'printfont' */ EXTERN char_u *p_popt; /* 'printoptions' */ diff --git a/src/os_mac.c b/src/os_mac.c --- a/src/os_mac.c +++ b/src/os_mac.c @@ -1301,27 +1301,27 @@ mch_copy_file_attribute(from, to) char_u *from; char_u *to; { - FSSpec frFSSpec; - FSSpec toFSSpec; - FInfo fndrInfo; - Str255 name; - ResType type; - ResType sink; - Handle resource; - short idxTypes; - short nbTypes; - short idxResources; - short nbResources; - short ID; - short frRFid; - short toRFid; - short attrs_orig; - short attrs_copy; - short temp; + FSSpec frFSSpec; + FSSpec toFSSpec; + FInfo fndrInfo; + Str255 name; + ResType type; + ResType sink; + Handle resource; + short idxTypes; + short nbTypes; + short idxResources; + short nbResources; + short ID; + short frRFid; + short toRFid; + short attrs_orig; + short attrs_copy; + short temp; /* TODO: Handle error */ - (void) GetFSSpecFromPath (from, &frFSSpec); - (void) GetFSSpecFromPath (to , &toFSSpec); + (void)GetFSSpecFromPath(from, &frFSSpec); + (void)GetFSSpecFromPath(to , &toFSSpec); /* Copy resource fork */ temp = 0; @@ -1332,51 +1332,51 @@ mch_copy_file_attribute(from, to) if (frRFid != -1) { FSpCreateResFile(&toFSSpec, 'TEXT', UNKNOWN_CREATOR, 0); - toRFid = FSpOpenResFile (&toFSSpec, fsRdWrPerm); + toRFid = FSpOpenResFile(&toFSSpec, fsRdWrPerm); - UseResFile (frRFid); + UseResFile(frRFid); nbTypes = Count1Types(); for (idxTypes = 1; idxTypes <= nbTypes; idxTypes++) { - Get1IndType (&type, idxTypes); - nbResources = Count1Resources(type); + Get1IndType(&type, idxTypes); + nbResources = Count1Resources(type); - for (idxResources = 1; idxResources <= nbResources; idxResources++) - { - attrs_orig = 0; /* in case GetRes fails */ - attrs_copy = 0; /* in case GetRes fails */ - resource = Get1IndResource(type, idxResources); - GetResInfo (resource, &ID, &sink, name); - HLock (resource); - attrs_orig = GetResAttrs (resource); - DetachResource (resource); + for (idxResources = 1; idxResources <= nbResources; idxResources++) + { + attrs_orig = 0; /* in case GetRes fails */ + attrs_copy = 0; /* in case GetRes fails */ + resource = Get1IndResource(type, idxResources); + GetResInfo(resource, &ID, &sink, name); + HLock(resource); + attrs_orig = GetResAttrs(resource); + DetachResource(resource); - UseResFile (toRFid); - AddResource (resource, type, ID, name); - attrs_copy = GetResAttrs (resource); - attrs_copy = (attrs_copy & 0x2) | (attrs_orig & 0xFD); - SetResAttrs (resource, attrs_copy); - WriteResource (resource); - UpdateResFile (toRFid); + UseResFile(toRFid); + AddResource(resource, type, ID, name); + attrs_copy = GetResAttrs(resource); + attrs_copy = (attrs_copy & 0x2) | (attrs_orig & 0xFD); + SetResAttrs(resource, attrs_copy); + WriteResource(resource); + UpdateResFile(toRFid); - temp = GetResAttrs (resource); + temp = GetResAttrs(resource); - /*SetResAttrs (resource, 0);*/ - HUnlock(resource); - ReleaseResource (resource); - UseResFile (frRFid); + /*SetResAttrs (resource, 0);*/ + HUnlock(resource); + ReleaseResource(resource); + UseResFile(frRFid); } } - CloseResFile (toRFid); - CloseResFile (frRFid); - } + CloseResFile(toRFid); + CloseResFile(frRFid); + } #endif /* Copy Finder Info */ - (void) FSpGetFInfo (&frFSSpec, &fndrInfo); - (void) FSpSetFInfo (&toFSSpec, &fndrInfo); + (void)FSpGetFInfo(&frFSSpec, &fndrInfo); + (void)FSpSetFInfo(&toFSSpec, &fndrInfo); return (temp == attrs_copy); } @@ -1386,13 +1386,13 @@ mch_has_resource_fork (file) char_u *file; { FSSpec fileFSSpec; - short fileRFid; + short fileRFid; /* TODO: Handle error */ - (void) GetFSSpecFromPath (file, &fileFSSpec); - fileRFid = FSpOpenResFile (&fileFSSpec, fsCurPerm); + (void)GetFSSpecFromPath(file, &fileFSSpec); + fileRFid = FSpOpenResFile(&fileFSSpec, fsCurPerm); if (fileRFid != -1) - CloseResFile (fileRFid); + CloseResFile(fileRFid); return (fileRFid != -1); } diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro --- a/src/proto/ex_getln.pro +++ b/src/proto/ex_getln.pro @@ -9,6 +9,7 @@ colnr_T cmdline_getvcol_cursor __ARGS((v void putcmdline __ARGS((int c, int shift)); void unputcmdline __ARGS((void)); int put_on_cmdline __ARGS((char_u *str, int len, int redraw)); +void cmdline_paste_str __ARGS((char_u *s, int literally)); void redrawcmdline __ARGS((void)); void redrawcmd __ARGS((void)); void compute_cmdrow __ARGS((void)); diff --git a/src/proto/ops.pro b/src/proto/ops.pro --- a/src/proto/ops.pro +++ b/src/proto/ops.pro @@ -10,13 +10,16 @@ int get_expr_register __ARGS((void)); void set_expr_line __ARGS((char_u *new_line)); char_u *get_expr_line __ARGS((void)); int valid_yank_reg __ARGS((int regname, int writing)); +void get_yank_register __ARGS((int regname, int writing)); +int may_get_selection __ARGS((int regname)); void *get_register __ARGS((int name, int copy)); void put_register __ARGS((int name, void *reg)); int yank_register_mline __ARGS((int regname)); int do_record __ARGS((int c)); int do_execreg __ARGS((int regname, int colon, int addcr)); int insert_reg __ARGS((int regname, int literally)); -int cmdline_paste __ARGS((int regname, int literally)); +int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg)); +int cmdline_paste_reg __ARGS((int regname, int literally)); void adjust_clip_reg __ARGS((int *rp)); int op_delete __ARGS((oparg_T *oap)); int op_replace __ARGS((oparg_T *oap, int c));