Example #1
0
        public string Stringify()
        {
            string outp   = "";
            string joiner = "";

            for (int y = 0; y < height; y++)
            {
                outp  += joiner;
                joiner = "<br>";
                for (int x = 0; x < width; x++)
                {
                    TerminalChar toDraw   = char_array[y][x];
                    string       to_Write = "";
                    if (toDraw.topic != "" && !(x > 0 && toDraw.topic == char_array[y][x - 1].topic))
                    {
                        to_Write += String.Format("<a style='text-decoration:none;' href='?src={0};PRG_topic={1}'>", computer_ref, HttpUtility.UrlEncode(toDraw.topic));
                    }
                    if (!(x > 0 && toDraw.Like(char_array[y][x - 1])))
                    {
                        to_Write += String.Format("<span style=\"color:{0};background-color:{1}\">", toDraw.foreground.toHTML(), toDraw.background.toHTML());
                    }
                    to_Write += encode(toDraw.text);
                    if (!(x < width - 1 && toDraw.Like(char_array[y][x + 1])))
                    {
                        to_Write += "</span>";
                    }
                    if (toDraw.topic != "" && !(x < width - 1 && toDraw.topic == char_array[y][x + 1].topic))
                    {
                        to_Write += "</a>";
                    }
                    outp += to_Write;
                }
            }
            return(outp);
        }
Example #2
0
 public void Write(String str)
 {
     foreach (char c in str)
     {
         if (c == '\r')
         {
             cursor_x = 0;
         }
         else if (c == '\n')
         {
             MoveDown();
         }
         else if (c == '\t')
         {
             MoveRight();
             while (cursor_x % 4 > 0)
             {
                 MoveRight();
             }
         }
         else
         {
             char_array[cursor_y][cursor_x] = new TerminalChar(c, background, foreground, "");
             MoveRight();
         }
     }
 }
Example #3
0
 public bool Like(TerminalChar other)
 {
     return(background.r == other.background.r &&
            background.g == other.background.g &&
            background.b == other.background.b &&
            foreground.r == other.foreground.r &&
            foreground.g == other.foreground.g &&
            foreground.b == other.foreground.b);
 }
Example #4
0
 public void Clear()
 {
     cursor_x   = 0;
     cursor_y   = 0;
     char_array = new TerminalChar[height][];
     for (int y = 0; y < height; y++)
     {
         char_array[y] = new TerminalChar[width];
         for (int x = 0; x < width; x++)
         {
             char_array[y][x] = new TerminalChar(' ', background, foreground, "");
         }
     }
 }
Example #5
0
 public void MoveDown()
 {
     cursor_y++;
     if (cursor_y >= height)
     {
         cursor_y--;
         for (int i = 0; i < height - 1; i++)
         {
             char_array[i] = char_array[i + 1];
         }
         char_array[height - 1] = new TerminalChar[width];
         for (int x = 0; x < width; x++)
         {
             char_array[height - 1][x] = new TerminalChar(' ', background, foreground, "");
         }
     }
 }