private void realWrite(string str, string topic = null)
 {
     foreach (char c in str)
     {
         if (c == '\r')
         {
             cursorX = 0;
         }
         else if (c == '\n')
         {
             cursorX = 0;
             MoveDown();
         }
         else if (c == '\t')
         {
             MoveRight();
             while (cursorX % 4 > 0)
             {
                 MoveRight();
             }
         }
         else
         {
             lock (char_array)
             {
                 char_array[cursorY][cursorX] = new TerminalChar(c, background, foreground, topic);
             }
             MoveRight();
         }
     }
 }
 public void clear()
 {
     cursorX    = 0;
     cursorY    = 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);
         }
     }
 }
示例#3
0
        public void Scroll()
        {
            TerminalChar[] newOutput = new TerminalChar[xCount * yCount];
            cursorY = yCount - 1;

            for (int xx = 0; xx < xCount; xx++)
            {
                for (int yy = 0; yy < yCount; yy++)
                {
                    newOutput[xx + (yy * xCount)] = output[xx + (((yy + 1) % yCount) * xCount)];
                }
            }
            output = newOutput;
        }
示例#4
0
        public void PutCharNext(char c, uint fg)
        {
            TerminalChar ch = new TerminalChar()
            {
                character = c, backColor = backColor, foreColor = fg
            };

            output[cursorX + (cursorY * xCount)] = ch;
            cursorX++;
            if (cursorY >= yCount)
            {
                Scroll();
            }
        }
 public void MoveDown()
 {
     cursorY++;
     if (cursorY >= height)
     {
         cursorY--;
         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);
         }
     }
 }
示例#6
0
 public void Write(string txt, uint fg)
 {
     foreach (char c in txt)
     {
         TerminalChar ch = new TerminalChar()
         {
             character = c, backColor = backColor, foreColor = fg
         };
         output[cursorX + (cursorY * xCount)] = ch;
         cursorX++;
         if (cursorX >= xCount)
         {
             cursorX = 0; cursorY++;
         }
     }
     if (cursorY >= yCount)
     {
         Scroll();
     }
     reading = true;
 }
示例#7
0
        public override void Update()
        {
            // update base
            UpdateWindow();
            base.Update();

            if (state != WindowState.minimized)
            {
                if (ProcessManager.selWindowID == id)
                {
                    tick = Clock.GetSecond();
                    if (tick != prevSec)
                    {
                        cursor  = !cursor;
                        prevSec = tick;
                    }
                }

                if (oldState != state)
                {
                    int            newX    = (width - 16) / 7;
                    int            newY    = (height - 20 - 16) / 11;
                    TerminalChar[] termNew = new TerminalChar[newX * newY];

                    if (state == WindowState.maximized)
                    {
                        for (int xx = 0; xx < xCount; xx++)
                        {
                            for (int yy = 0; yy < yCount; yy++)
                            {
                                termNew[xx + (yy * newX)] = output[xx + (yy * xCount)];
                            }
                        }
                    }
                    else if (state == WindowState.normal)
                    {
                        for (int xx = 0; xx < newX; xx++)
                        {
                            for (int yy = 0; yy < newY; yy++)
                            {
                                termNew[xx + (yy * newX)] = output[xx + (yy * xCount)];
                            }
                        }
                    }

                    xCount   = newX;
                    yCount   = newY;
                    output   = termNew;
                    oldState = state;
                }

                if (reading)
                {
                    // get input
                    kbReader.GetInput();
                    input = kbReader.output;

                    // white input to char array
                    if (input != inputOld)
                    {
                        cursorX = lastX;
                        for (int nx = cursorX; nx < xCount; nx++)
                        {
                            output[nx + (cursorY * xCount)] = null;
                        }
                        foreach (char c in input)
                        {
                            PutCharNext(c, Color.white);
                        }
                    }

                    // max length
                    if (input.Length >= xCount - 7)
                    {
                        input = input.Remove(input.Length - 1, 1); kbReader.output = input;
                    }

                    // set old input
                    inputOld = input;

                    // check enter press
                    if (KBPS2.ENTER_DOWN)
                    {
                        ParseCommand(input);
                        kbReader.output = "";
                        input           = "";
                    }
                }
                else
                {
                    kbReader.output = "";
                    input           = "";
                }
            }
        }