URI:
       lang_rtf.st - enscript - GNU Enscript
  HTML git clone git://thinkerwim.org/enscript.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       lang_rtf.st (1743B)
       ---
            1 /*
            2  * Definition for RTF output
            3  * Kevin Grover, <grover@wizard.com>
            4  */
            5 
            6 state lang_rtf
            7 {
            8   BEGIN {
            9     sub rtf_color_map()
           10       {
           11         local i;
           12 
           13         print ("{\\colortbl;");
           14         for (i = 0; i < length (rgb_values); i = i + 1)
           15           print (sprintf ("\\red%d\\green%d\\blue%d;",
           16                           rgb_values[i][1],
           17                           rgb_values[i][2],
           18                           rgb_values[i][3]));
           19 
           20         print ("}\n");
           21 
           22         return;
           23       }
           24 
           25     sub language_color (name)
           26       {
           27         local idx;
           28 
           29         idx = color_index (name);
           30         if (idx < 0)
           31           panic ("unknown color `", name, "'");
           32 
           33         return sprintf("\\cf%d", idx + 1);
           34       }
           35 
           36     LANGUAGE_SPECIALS = /[\\{}\n]/;
           37 
           38     sub language_print (str)
           39       {
           40         str = regsuball (str, /\\\\/, "\\\\");
           41         str = regsuball (str, /{/, "\\{");
           42         str = regsuball (str, /}/, "\\}");
           43         str = regsuball (str, /\n/, "\\line\n");
           44         print (str);
           45       }
           46 
           47     sub language_symbol (symbol)
           48       {
           49         return false;
           50       }
           51 
           52     sub header ()
           53       {
           54         local i;
           55 
           56         if (current_input_file == 1)
           57           {
           58             print ("{\\rtf\\ansi\\deff0\n");
           59             print ("{\\fonttbl{\\f0\\fswiss Courier New;}}\n");
           60             rtf_color_map();
           61           }
           62       }
           63 
           64     sub trailer ()
           65       {
           66         if (current_input_file == int (num_input_files))
           67           print ("}\n");
           68       }
           69 
           70     sub color_on (name)
           71       {
           72         print ("{", name, " ");
           73       }
           74 
           75     sub color_off ()
           76       {
           77         print ("}");
           78       }
           79 
           80     sub face_on (face)
           81       {
           82         if (face[boldp] || face[italicp])
           83           {
           84             print ("{");
           85             if (face[boldp])
           86               print ("\\b");
           87             if (face[italicp])
           88               print ("\\i");
           89             print (" ");
           90           }
           91 
           92         if (face[fg_color])
           93           color_on (face[fg_color]);
           94       }
           95 
           96     sub face_off (face)
           97       {
           98         if (face[fg_color])
           99           color_off ();
          100         if (face[boldp] || face[italicp])
          101           print ("}");
          102       }
          103 
          104     return;
          105   }
          106 }
          107 
          108 
          109 /*
          110 Local variables:
          111 mode: c
          112 End:
          113 */