403Webshell
Server IP : 172.67.134.114  /  Your IP : 104.23.197.122
Web Server : Apache/2.4.37
System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64
User : ricodeal ( 1046)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/enscript/hl/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/enscript/hl/lang_ansi.st
/*
 * Definitions for the ANSI color tty outputs.
 * Author: Bill Petheram <[email protected]>
 *	   Markku Rossi <[email protected]>
 */

state lang_ansi
{
  BEGIN {
    /* The current face as an ANSI str. */
    ansi_face_str = 0;

    ansi_face_stack = list();
    ansi_face_stack_pos = 0;

    ansi_color_table = list();
    ansi_color_table_size = 0;

    sub ansi_define_color(ansi, r, g, b)
      {
	ansi_color_table[ansi_color_table_size] = list(ansi, r, g, b);
	ansi_color_table_size = ansi_color_table_size + 1;
      }

    ansi_define_color(30, 0,   0,   0); 	/* black */
    ansi_define_color(31, 205, 0,   0); 	/* red3 */
    ansi_define_color(32, 0,   205, 0);  	/* green3 */
    ansi_define_color(33, 205, 205, 0);		/* yellow3 */
    ansi_define_color(34, 0,   0,   205);	/* blue3 */
    ansi_define_color(35, 205, 0,   205);	/* magenta3 */
    ansi_define_color(36, 0,   205, 205);	/* cyan3 */
    ansi_define_color(37, 229, 229, 229);	/* gray90 */

    ansi_define_color(90, 77,  77,  77); 	/* gray30 */
    ansi_define_color(91, 255, 0,   0); 	/* red */
    ansi_define_color(92, 0,   255, 0);  	/* green */
    ansi_define_color(93, 255, 255, 0);		/* yellow */
    ansi_define_color(94, 0,   0,   255);	/* blue */
    ansi_define_color(95, 255, 0,   255);	/* magenta */
    ansi_define_color(96, 0,   255, 255);	/* cyan */
    ansi_define_color(97, 255, 255, 255);	/* white */

    sub ansi_count_delta(a, b)
      {
	local delta = a - b;

	if (delta < 0)
	  delta = 0 - delta;

	return delta * delta;
      }

    sub ansi_count_color_delta(ansi_color, r, g, b)
      {
	local delta = 0;

	delta += ansi_count_delta(ansi_color[1], r);
	delta += ansi_count_delta(ansi_color[2], g);
	delta += ansi_count_delta(ansi_color[3], b);

	return delta;
      }

    sub map_color(r, g, b)
      {
	local i, min = 65536, min_color = 0, delta;

	for (i = 0; i < ansi_color_table_size; i++)
	  {
	    delta = ansi_count_color_delta(ansi_color_table[i], r, g, b);
	    if (delta < min)
	      {
		min_color = ansi_color_table[i][0];
		min = delta;
	      }
	  }
	if (min > 16384)
	  /* Don't accept too bad matches. */
	  min_color = 0;

	return min_color;
      }

    LANGUAGE_SPECIALS = /\n/;

    sub language_print(str)
      {
	if (ansi_face_str)
	  str = regsuball(str, /\n/, concat("\033[0m\n", ansi_face_str));

	print(str);
      }

    sub header()
      {
      }

    sub trailer()
      {
	print("\033[0m");
      }

    sub ansi_set_face(face)
      {
	local b = "", i = "", fg ="", bg = "";

	if (face[boldp])
	  b = ";1";
	if (face[italicp])
	  i = ";4";
	if (face[fg_color])
	  fg = concat(";", string(face[fg_color]));
	if (face[bg_color])
	  bg = concat(";", string(face[bg_color] + 10));

	ansi_face_str = concat("\033[0", b, i, fg, bg, "m");

	print(ansi_face_str);
      }

    sub face_on(face)
      {
	ansi_face_stack[ansi_face_stack_pos++] = face;
	ansi_set_face(face);
      }

    sub face_off(face)
      {
	if (ansi_face_stack_pos > 0)
	  /* Just to make sure that we don't fail on some broken
             highlighting rules.  */
	  ansi_face_stack_pos--;

	if (ansi_face_stack_pos == 0)
	  {
	    print("\033[0m");
	    ansi_face_str = 0;
	  }
	else
	  ansi_set_face(ansi_face_stack[ansi_face_stack_pos - 1]);
      }

    return;
  }
}

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

Youez - 2016 - github.com/yon3zu
LinuXploit