public colorchar[,] GetCurrentPanel()
 {
     colorchar[,] result = new colorchar[H, W];
     for (int i = 0; i < H; ++i)
     {
         for (int j = 0; j < W; ++j)
         {
             result[i, j] = Screen.Char(row + i, col + j);
         }
     }
     return(result);
 }
 public static colorchar[,] GetCurrentRect(int row, int col, int height, int width)
 {
     colorchar[,] result = new colorchar[height, width];
     for (int i = 0; i < height; ++i)
     {
         for (int j = 0; j < width; ++j)
         {
             result[i, j] = Char(row + i, col + j);
         }
     }
     return(result);
 }
 public static colorchar[,] GetCurrentScreen()
 {
     colorchar[,] result = new colorchar[H, W];
     for (int i = 0; i < H; ++i)
     {
         for (int j = 0; j < W; ++j)
         {
             result[i, j] = Char(i, j);
         }
     }
     return(result);
 }
 public static void Write(int r, int c, colorchar ch)
 {
     if (!memory[r, c].Equals(ch))
     {
         memory[r, c] = ch;
         if (ch.color != ForegroundColor)
         {
             ForegroundColor = ch.color;
         }                                                                                              //note: I changed Console.BackgroundColor to BackgroundColor on the next line. hope it didn't break anything.
         if (ch.bgcolor != BackgroundColor || (linux && ch.c == ' ' && ch.color == ConsoleColor.Black)) //voodoo here. not sure why this is needed. (possible Mono bug)
         {
             BackgroundColor = ch.bgcolor;
         }
         Console.SetCursorPosition(c, r);
         Console.Write(ch.c);
     }
 }
        public static void DrawRectangularPartOfArray(colorchar[,] array, int row, int col, int height, int width)
        {
            colorstringpart s;

            s.s       = "";
            s.bgcolor = ConsoleColor.Black;
            s.color   = ConsoleColor.Black;
            int current_c = col;

            for (int i = row; i < row + height; ++i)
            {
                s.s       = "";
                current_c = col;
                for (int j = col; j < col + width; ++j)
                {
                    colorchar ch = array[i, j];
                    if (ch.color != s.color)
                    {
                        if (s.s.Length > 0)
                        {
                            Screen.Write(i, current_c, s);
                            s.s       = "";
                            s.s      += ch.c;
                            s.color   = ch.color;
                            current_c = j;
                        }
                        else
                        {
                            s.s    += ch.c;
                            s.color = ch.color;
                        }
                    }
                    else
                    {
                        s.s += ch.c;
                    }
                }
                Screen.Write(i, current_c, s);
            }
        }
 public void Write(int r, int c, colorchar ch)
 {
     Screen.Write(row + r, col + c, ch);
 }