To: [email protected]
Subject: Patch 5.6a.002
Fcc: outbox
From: Bram Moolenaar <[email protected]>
------------

Patch 5.6a.002
Problem:    The script for conversion to HTML was an older version.
Solution:   Add support for running 2html.vim on a color terminal.
Files:      runtime/syntax/2html.vim


*** ../vim-5.6a.1/runtime/syntax/2html.vim      Sun Dec 19 19:44:52 1999
--- runtime/syntax/2html.vim    Tue Dec 21 19:37:05 1999
***************
*** 1,6 ****
 " Vim syntax support file
 " Maintainer: Bram Moolenaar <[email protected]>
! " Last change:        1999 May 07

 " Transform a file into HTML, using the current syntax highlighting.

--- 1,6 ----
 " Vim syntax support file
 " Maintainer: Bram Moolenaar <[email protected]>
! " Last change:        1999 Dec 21

 " Transform a file into HTML, using the current syntax highlighting.

***************
*** 38,43 ****
--- 38,80 ----
       return substitute(a:attr, '.', '<&>', 'g') . bgs . fgs . substitute(substitute(substitute(substitute(substitute(a:txt, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<HR class=PAGE-BREAK>', 'g') . fge . bge . substitute(a:attr[2] . a:attr[1] . a:attr[0], '.', '</&>', 'g')
 endfun

+
+ if &t_Co == 8
+   let cterm_color0  = "#808080"
+   let cterm_color1  = "#ff6060"
+   let cterm_color2  = "#00ff00"
+   let cterm_color3  = "#ffff00"
+   let cterm_color4  = "#8080ff"
+   let cterm_color5  = "#ff40ff"
+   let cterm_color6  = "#00ffff"
+   let cterm_color7  = "#ffffff"
+ else
+   let cterm_color0  = "#000000"
+   let cterm_color1  = "#c00000"
+   let cterm_color2  = "#008000"
+   let cterm_color3  = "#804000"
+   let cterm_color4  = "#0000c0"
+   let cterm_color5  = "#c000c0"
+   let cterm_color6  = "#008080"
+   let cterm_color7  = "#c0c0c0"
+   let cterm_color8  = "#808080"
+   let cterm_color9  = "#ff6060"
+   let cterm_color10 = "#00ff00"
+   let cterm_color11 = "#ffff00"
+   let cterm_color12 = "#8080ff"
+   let cterm_color13 = "#ff40ff"
+   let cterm_color14 = "#00ffff"
+   let cterm_color15 = "#ffffff"
+ endif
+
+ function! HTMLColor(c)
+   if exists("g:cterm_color" . a:c)
+     execute "return g:cterm_color" . a:c
+   else
+     return ""
+   endif
+ endfun
+
 " Set some options to make it work faster.
 " Expand tabs in original buffer to get 'tabstop' correctly used.
 let old_title = &title
***************
*** 55,62 ****
 1,$d
 set noet
 " Find out the background and foreground color.
! let bg = synIDattr(highlightID("Normal"), "bg#", "gui")
! let fg = synIDattr(highlightID("Normal"), "fg#", "gui")
 if bg == ""
    if &background == "dark"
      let bg = "#000000"
--- 92,104 ----
 1,$d
 set noet
 " Find out the background and foreground color.
! if has("gui_running")
!   let bg = synIDattr(highlightID("Normal"), "bg#", "gui")
!   let fg = synIDattr(highlightID("Normal"), "fg#", "gui")
! else
!   let bg = HTMLColor(synIDattr(highlightID("Normal"), "bg", "cterm"))
!   let fg = HTMLColor(synIDattr(highlightID("Normal"), "fg", "cterm"))
! endif
 if bg == ""
    if &background == "dark"
      let bg = "#000000"
***************
*** 82,90 ****
 exe "normal \<C-W>p"

 " Some 'constants' for ease of addressing with []
! let uline="U"
! let bld="B"
! let itl="I"

 " Loop over all lines in the original text
 let end = line("$")
--- 124,132 ----
 exe "normal \<C-W>p"

 " Some 'constants' for ease of addressing with []
! let uline = "U"
! let bld = "B"
! let itl = "I"

 " Loop over all lines in the original text
 let end = line("$")
***************
*** 116,122 ****
     " output the text with the same synID, with all its attributes
     " The first part turns attributes into  [U][I][B]
     let id = synIDtrans(id)
!     let new = new . HTMLPutText(uline[synIDattr(id, "underline", "gui") - 1] . itl[synIDattr(id, "italic", "gui") - 1] . bld[synIDattr(id, "bold", "gui") - 1], synIDattr(id, "bg#", "gui"), synIDattr(id, "fg#", "gui"), strpart(line, startcol - 1, col - startcol))
     if col > len
       break
     endif
--- 158,168 ----
     " output the text with the same synID, with all its attributes
     " The first part turns attributes into  [U][I][B]
     let id = synIDtrans(id)
!     if has("gui_running")
!       let new = new . HTMLPutText(uline[synIDattr(id, "underline", "gui") - 1] . itl[synIDattr(id, "italic", "gui") - 1] . bld[synIDattr(id, "bold", "gui") - 1], synIDattr(id, "bg#", "gui"), synIDattr(id, "fg#", "gui"), strpart(line, startcol - 1, col - startcol))
!     else
!       let new = new . HTMLPutText(uline[synIDattr(id, "underline", "cterm") - 1] . itl[synIDattr(id, "italic", "cterm") - 1] . bld[synIDattr(id, "bold", "cterm") - 1], HTMLColor(synIDattr(id, "bg", "cterm")), HTMLColor(synIDattr(id, "fg", "cterm")), strpart(line, startcol - 1, col - startcol))
!     endif
     if col > len
       break
     endif
***************
*** 143,146 ****
 let startcol = 0
 let id = 0
 unlet uline bld itl lnum end col startcol line len new id
! unlet old_title old_icon old_paste old_et did_retab
--- 189,200 ----
 let startcol = 0
 let id = 0
 unlet uline bld itl lnum end col startcol line len new id
! unlet old_title old_icon old_paste old_et did_retab bg fg
! unlet cterm_color0 cterm_color1 cterm_color2 cterm_color3
! unlet cterm_color4 cterm_color5 cterm_color6 cterm_color7
! if &t_Co != 8
!   unlet cterm_color8 cterm_color9 cterm_color10 cterm_color11
!   unlet cterm_color12 cterm_color13 cterm_color14 cterm_color15
! endif
! delfunc HTMLPutText
! delfunc HTMLColor
*** ../vim-5.6a.1/src/version.c Mon Dec 20 10:02:22 1999
--- src/version.c       Tue Dec 21 11:31:12 1999
***************
*** 420,421 ****
--- 420,423 ----
 {   /* Add new patch number below this line */
+ /**/
+     2,
 /**/

--
Biting someone with your natural teeth is "simple assault," while biting
someone with your false teeth is "aggravated assault."
               [real standing law in Louisana, United States of America]

--/-/---- Bram Moolenaar ---- [email protected] ---- [email protected] ---\-\--
 \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /