[BACK]Return to lang_cvsweb_diff.st CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / cvsweb / enscript

File: [cvsweb.bsd.lv] / cvsweb / enscript / Attic / lang_cvsweb_diff.st (download)

Revision 3.1, Sat Feb 14 17:25:04 2004 UTC (18 years, 9 months ago) by scop
Branch: MAIN
CVS Tags: FreeBSD-cvsweb-3_0_6, FreeBSD-cvsweb-3_0_5, FreeBSD-cvsweb-3_0_4, FreeBSD-cvsweb-3_0_3, FreeBSD-cvsweb-3_0_2, FreeBSD-cvsweb-3_0_1, FreeBSD-cvsweb-3_0_0, FreeBSD-cvsweb-2_9_3-beta

Use a separate Enscript language file for diffs, and tune it for better
diff readability.

Submitted by:	Christopher Wolf <wolf@ti.com> (modified)

/*
   GNU Enscript language file for FreeBSD-CVSweb diffs.
   $FreeBSD$
 */

state lang_cvsweb_diff
{
  BEGIN {
    /* RGB -> HTML color mapper function. */
    sub map_color (r, g, b)
      {
	return sprintf ("#%02X%02X%02X", r, g, b);
      }

    LANGUAGE_SPECIALS = /[<>\&\"]/;

    sub language_print (str)
      {
	str = regsuball (str, /\&/, "&amp;");
	str = regsuball (str, /</, "&lt;");
	str = regsuball (str, />/, "&gt;");
	str = regsuball (str, /\"/, "&quot;");
	print (str);
      }

    sub language_symbol (symbol)
      {
	return false;
      }

    sub header ()
      {
      }

    sub trailer ()
      {
      }

    sub face_on (face)
      {
	if (face[boldp])
	  print ("<b>");
	if (face[italicp])
	  print ("<i>");

	if (face[fg_color])
	  print ("<span style=\"color: ", face[fg_color], "; background-color: lightgrey\">");
	if (face[bg_color])
	  print ("<span style=\"background-color: ", face[bg_color], "\">");
      }

    sub face_off (face)
      {
 	if (face[fg_color])
	  print ("</span>");
 	if (face[bg_color])
	  print ("</span>");

	if (face[italicp])
	  print ("</i>");
	if (face[boldp])
	  print ("</b>");
      }

    return;
  }
}


/*
Local variables:
mode: c
End:
*/